Hide columns in all worksheets in workbook

Vicky9063

Board Regular
Joined
Oct 27, 2005
Messages
79
Hi guys,
I have the following code which i am trying to use to hide a few of the same columns in each sheet of my workbook. However it only hides the columns in the activesheet. Is there something that I am missing?? THanks!


Code:
Sub UnhideWorksheetsktoAT()

' UnhideWorksheetsktoAT Macro
' Testing - use to open up worksheets where calcs are
'
Dim wsSheet As Worksheet
    For Each wsSheet In Worksheets
    Columns("m:Av").Select
    Selection.EntireColumn.Hidden = True
    Next wsSheet
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub UnhideWorksheetsktoAT()

' UnhideWorksheetsktoAT Macro
' Testing - use to open up worksheets where calcs are
'
Dim wsSheet As Worksheet
    For Each wsSheet In Worksheets
        wsSheet.Columns("m:Av").Hidden = True
    Next wsSheet
End Sub
 

Vicky9063

Board Regular
Joined
Oct 27, 2005
Messages
79
Thanks very much VoG it worked! Sorry for the late reply I havent been getting my email notifications..
cheers
vb
 

Watch MrExcel Video

Forum statistics

Threads
1,133,382
Messages
5,658,492
Members
418,447
Latest member
AdamAl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top