Hidden Column in VBA

  • Thread starter Thread starter norika
  • Start date Start date
N

norika

Selecting 'Group Sheet' and hide column using VBA.

Sheets(Array("sheet1", "sheet2", "sheet3")).Select
Sheets("sheet1").Activate
Range("A:A,D:F,J:J,N:O").Select
Selection.EntireColumn.Hidden = True

The result was only "Sheet1" can hide the column, the other cannot.

Any ideas?

Norika
 
I don't know about the one line solution, but here's one way:

Sub test()
Dim wks As Worksheet

For Each wks In Sheets(Array("Sheet1", "Sheet2"))
wks.Range("A:A").EntireColumn.Hidden = True
Next
End Sub
 
hi
From book by Green et al "...However, only the active sheet is
affected when you apply changes to a grouped sheet using VBA
code...you need to set up a for...each...next loop to carry out
changes on each member."

regards
Paul
 
How do I change the command line and let me go to cell A1?

I try to change
from wks.Range("A:A").EntireColumn.Hidden = True
to wks.Range("A1").Select

Of course, it failed.

Norika
 
Back
Top