Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default hide colum based on cell value on each worksheets

I have a workbook with several worksheets. I am trying to write a VBA
macro that would look at row 5 to see if any cells indicate "Hide
column". If it does, it would hide all the columns indicating "Hide
column" on this worksheet. Then it would continue the same process to
the next worksheet, and the next one ...

I currently have the macro working for the individual worksheet (see
below), but I would like to have it work to do all the worksheets of
the workbook.

Sub HideColumn()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For a = 5 To 200
If Range("A5").Offset(0, a).Value = "Hide column" Then Range
("A5").Offset(0, a).EntireColumn.Hidden = True
Next a
Application.ScreenUpdating = True

Thanks in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default hide colum based on cell value on each worksheets

Hi

This should do it:

Sub HideColumn()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each sh In ThisWorkbook.Sheets
For a = 5 To 200
If sh.Range("A5").Offset(0, a).Value = "Hide column" Then
sh.Range("A5").Offset(0, a).EntireColumn.Hidden = True
End If
Next a
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Regards,
Per

"Norvascom" skrev i meddelelsen
...
I have a workbook with several worksheets. I am trying to write a VBA
macro that would look at row 5 to see if any cells indicate "Hide
column". If it does, it would hide all the columns indicating "Hide
column" on this worksheet. Then it would continue the same process to
the next worksheet, and the next one ...

I currently have the macro working for the individual worksheet (see
below), but I would like to have it work to do all the worksheets of
the workbook.

Sub HideColumn()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For a = 5 To 200
If Range("A5").Offset(0, a).Value = "Hide column" Then Range
("A5").Offset(0, a).EntireColumn.Hidden = True
Next a
Application.ScreenUpdating = True

Thanks in advance for your help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default hide colum based on cell value on each worksheets

On Feb 1, 2:25*am, "Per Jessen" wrote:
Hi

This should do it:

Sub HideColumn()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each sh In ThisWorkbook.Sheets
* * For a = 5 To 200
* * * * If sh.Range("A5").Offset(0, a).Value = "Hide column" Then
* * * * * * sh.Range("A5").Offset(0, a).EntireColumn.Hidden = True
* * * * End If
* * Next a
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Regards,
Per

"Norvascom" skrev i ...



I have a workbook with several worksheets. I am trying to write a VBA
macro that would look at row 5 to see if any cells indicate "Hide
column". If it does, it would hide all the columns indicating "Hide
column" on this worksheet. Then it would continue the same process to
the next worksheet, and the next one ...


I currently have the macro working for the individual worksheet (see
below), but I would like to have it work to do all the worksheets of
the workbook.


Sub HideColumn()
* *Application.ScreenUpdating = False
* *Application.Calculation = xlCalculationManual
* *For a = 5 To 200
* *If Range("A5").Offset(0, a).Value = "Hide column" Then Range
("A5").Offset(0, a).EntireColumn.Hidden = True
* *Next a
* *Application.ScreenUpdating = True


Thanks in advance for your help.- Hide quoted text -


- Show quoted text -


Thanks, it works perfectly.
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
Hide or display worksheets based on form Shawnn Excel Discussion (Misc queries) 3 December 31st 08 10:58 PM
I am trying to lookup a cell based upon what is in row 3 and colum David A. Excel Discussion (Misc queries) 6 July 18th 07 09:10 PM
Hide Worksheets based on value from Access DB Mike G - D.C. Excel Programming 0 June 22nd 06 07:44 PM
PROBLEM: hide/unhide worksheets based on cell value change [email protected] Excel Programming 3 May 31st 06 02:23 PM
Is there a way to hide worksheets and/or rows/columns based on information enter into a particular cell of range of cells? Marc New Users to Excel 1 March 10th 06 05:10 PM


All times are GMT +1. The time now is 09:38 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"