Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For each sheet in workbook


The following is meant to hide columns c-e in each worksheet in a
workbook.
Not quite working as it doesnt operate for each and every worksheet

Thanks in advance


Sub hidecols()
Dim sh As Worksheet


For Each sh In ThisWorkbook.Worksheets
Columns("C:E").Hidden = True
Next
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=532226

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default For each sheet in workbook

Hi T De Villiers

It always run the code on the same sheet (activesheet)

Use
Sh.Columns("C:E").Hidden = True


--
Regards Ron de Bruin
http://www.rondebruin.nl


"T De Villiers" wrote in message
news:T.De.Villiers.265hqz_1144844102.3895@excelfor um-nospam.com...

The following is meant to hide columns c-e in each worksheet in a
workbook.
Not quite working as it doesnt operate for each and every worksheet

Thanks in advance


Sub hidecols()
Dim sh As Worksheet


For Each sh In ThisWorkbook.Worksheets
Columns("C:E").Hidden = True
Next
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=532226



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default For each sheet in workbook



This code snipped worked fine on my PC.

Sub HideColumns()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
Columns("C:E").Hidden = True
Next ws

Set wb = Nothing
Set ws = Nothing
Exit Sub

End Sub
--
Kevin Backmann


"T De Villiers" wrote:


The following is meant to hide columns c-e in each worksheet in a
workbook.
Not quite working as it doesnt operate for each and every worksheet

Thanks in advance


Sub hidecols()
Dim sh As Worksheet


For Each sh In ThisWorkbook.Worksheets
Columns("C:E").Hidden = True
Next
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=532226


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default For each sheet in workbook

Sub gsnu()
Dim w As Worksheet
For Each w In Worksheets
w.Activate
Columns("C:E").Select
Selection.EntireColumn.Hidden = True
Next
End Sub

--
Gary''s Student


"T De Villiers" wrote:


The following is meant to hide columns c-e in each worksheet in a
workbook.
Not quite working as it doesnt operate for each and every worksheet

Thanks in advance


Sub hidecols()
Dim sh As Worksheet


For Each sh In ThisWorkbook.Worksheets
Columns("C:E").Hidden = True
Next
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=532226




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
Copy sheet cells into differnt workbook/sheet, How? IVLUTA Excel Discussion (Misc queries) 2 June 2nd 09 11:16 PM
Consolidate workbook sheets to another workbook sheet rudawg Excel Programming 1 March 15th 06 08:21 AM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Copy Sheet from One workbook to another EXISTING workbook Ken Soenen Excel Programming 0 February 12th 06 04:07 PM
automatic copy and paste from sheet to sheet in a workbook ramseyjramseyj Excel Programming 6 December 11th 04 12:37 AM


All times are GMT +1. The time now is 02:09 AM.

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

About Us

"It's about Microsoft Excel"