Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Hiding specific column on all worksheets

Hi,

I want to hide column A of all my worksheets. When I do this by hand
then everything is ok i.e. I select all worksheets and hide column A. So
I recorded a macro with these steps, here's the produced code:

Sub Macro2()
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub

However, when I now run the above macro, only column A of the first
sheet is hidden. What is wrong with the code?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hiding specific column on all worksheets

Sub Macro2()
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Columns("A:A").Hidden = True
Sheets("Sheet1").Select
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Scott Steiner" wrote in message
...
Hi,

I want to hide column A of all my worksheets. When I do this by hand
then everything is ok i.e. I select all worksheets and hide column A. So
I recorded a macro with these steps, here's the produced code:

Sub Macro2()
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub

However, when I now run the above macro, only column A of the first
sheet is hidden. What is wrong with the code?

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Hiding specific column on all worksheets

Hi Scott,
Try this,

Sub Macro3()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.Columns("A").Hidden = True
Next
End Sub

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
(Excel Add-ins)

*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding Formula Answers in Specific Cells pen Excel Worksheet Functions 1 May 4th 09 06:52 PM
hiding specific cells Ashley Excel Worksheet Functions 4 June 7th 08 12:34 AM
qn on counting in drop down menus and protecting/hiding specific worksheets qiong Excel Worksheet Functions 7 July 6th 07 10:30 PM
help... i might need a macro for this.. (hiding a specific # of ro Mo2 New Users to Excel 7 May 28th 07 08:13 AM
hiding specific columns Joe Black Excel Discussion (Misc queries) 3 September 22nd 05 10:35 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"