Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Hide Column Condition

Can anybody give me a macro for the following:

I have a list of item on row 2, with their corresponding category on
row 1 as per below:

Categ A CategB Categ A Gateg C Categ A Categ B
Item1 Item2 Item3 Item4 Item5 Item6

I would like to hide all column if categories in row 1 are not of
Category A

Thxs beforehand

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Hide Column Condition

Try:

Sub header()
Dim eCol As Integer
Dim i As Integer
eCol = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To eCol
With Cells(1, i)
If .Value < "Categ A" Then
.EntireColumn.Hidden = True
End If
End With
Next i
End Sub

Hope this helps
Rowan

al007 wrote:
Can anybody give me a macro for the following:

I have a list of item on row 2, with their corresponding category on
row 1 as per below:

Categ A CategB Categ A Gateg C Categ A Categ B
Item1 Item2 Item3 Item4 Item5 Item6

I would like to hide all column if categories in row 1 are not of
Category A

Thxs beforehand

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Hide Column Condition

Thxs a lot !! - One last favor - how can I make it work for
Sheet1,Sheet2 & Sheet3 with one same macro

Thxs
Rowan Drummond wrote:
Try:

Sub header()
Dim eCol As Integer
Dim i As Integer
eCol = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To eCol
With Cells(1, i)
If .Value < "Categ A" Then
.EntireColumn.Hidden = True
End If
End With
Next i
End Sub

Hope this helps
Rowan

al007 wrote:
Can anybody give me a macro for the following:

I have a list of item on row 2, with their corresponding category on
row 1 as per below:

Categ A CategB Categ A Gateg C Categ A Categ B
Item1 Item2 Item3 Item4 Item5 Item6

I would like to hide all column if categories in row 1 are not of
Category A

Thxs beforehand


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hide Column Condition


Enclose the main body of Rowan's code with a For...Next Loop:


For each sh in Worksheets
Sh.Activate

Code

Next


David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=483394

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
How do I auto hide a row if a condition isnt met? Brian Excel Discussion (Misc queries) 1 April 3rd 09 09:32 PM
How do I hide a combo_box on a condition? spannerj Excel Worksheet Functions 0 July 22nd 05 05:26 PM
Hide a row based on one cell's condition Brian Excel Worksheet Functions 1 March 19th 05 11:57 AM
How do I hide a column based on a condition (option not available. jgentillet Excel Worksheet Functions 0 January 24th 05 02:53 PM
Hide Columns On Condition Dominique Feteau[_2_] Excel Programming 6 January 22nd 05 08:16 AM


All times are GMT +1. The time now is 12:50 AM.

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"