Hide columns in multiple sheets

G

GregR

I am using this code to hide columns on multiple sheets:

Sheets(Array("04-329", "04-350", "05-001", "05-353", "05-354",
"06-011", "06-012", _
"06-013")).Select
Sheets("04-329").Activate

Range("H:H,L:U").Select
Range("S1").Activate
Selection.EntireColumn.Hidden = True

It works on the first sheet, but only selects the columns in the
remainder and does not hide them. What do I need to change to hide the
selection on all the sheets. TIA

Greg
 
D

Dave Peterson

I think I'd just cycle through those worksheets

dim wks as worksheet
for each wks in worksheets(Array("04-329", "04-350", "05-001", "05-353", _
"05-354", "06-011", "06-012", "06-013"))

wks.range("H:H,L:U").EntireColumn.Hidden = True
next wks
 
G

GregR

Dave, thank you, got it working with:

Sheets(Array("04-329", "04-350", "05-001", "05-353", "05-354", _
"06-011", "06-012", "06-013")).Select
For Each Sht In ActiveWindow.SelectedSheets
Sht.Range("H1,L1:U1").EntireColumn.Hidden = True
Next Sht

Greg
 
T

Tom Ogilvy

to prevent problems if you then edit a cell, you might want

Sheets(Array("04-329", "04-350", "05-001", "05-353", "05-354", _
"06-011", "06-012", "06-013")).Select
For Each Sht In ActiveWindow.SelectedSheets
Sht.Range("H1,L1:U1").EntireColumn.Hidden = True
Next Sht
sht.Select

to ungroup the sheets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top