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

Hi,
I referred back to another entry about hiding columns and tried to use it.
It didn't work. I created a drop down list in A5. Then all across from E1
to HE1, I used a simple if statement if the headers in row 6 equal to what
the selected drop down is, then is give value of 1, else blank. Question is,
why doesn't this work? Please help.

Dim c As Range
Dim varvalue As Variant
For Each c In Application.Intersect(ActiveSheet.UsedRange,
ActiveSheet.Range("E1:HI1")).Cells
varvalue = c.Value
If IsNumeric(varvalue) Then
If varvalue < 1 Then
c.EntireColumn.Hidden = True
End If
End If
Next c


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Hide Columns

Hey Don,

Boy, you are so smart! It is most definitely simpler. I added this line
first, to unhide all the cells first prior to the "selection".
Range("A:HB").EntireColumn.Hidden = False

It works beautifully. Thanks a million.

MrRJ

"Don Guillett" wrote:


why not a simpler approach
Sub hidecolsif()
For Each c In Range("e1:hl1")
If c = 1 Then Columns(c.Column).Hidden = True
Next c
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MrRJ" wrote in message
...
Hi,
I referred back to another entry about hiding columns and tried to use it.
It didn't work. I created a drop down list in A5. Then all across from
E1
to HE1, I used a simple if statement if the headers in row 6 equal to what
the selected drop down is, then is give value of 1, else blank. Question
is,
why doesn't this work? Please help.

Dim c As Range
Dim varvalue As Variant
For Each c In Application.Intersect(ActiveSheet.UsedRange,
ActiveSheet.Range("E1:HI1")).Cells
varvalue = c.Value
If IsNumeric(varvalue) Then
If varvalue < 1 Then
c.EntireColumn.Hidden = True
End If
End If
Next c




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
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
HIDE COLUMNS HIDE COLUMNS Excel Discussion (Misc queries) 3 July 5th 07 05:56 AM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
I set up a macro to hide/unhide columns. It hides more columns Lori Excel Programming 1 September 6th 06 04:08 PM
Excel button :: Filter columns by value - possible? Additionally, hide certain columns No Name Excel Programming 4 December 28th 04 07:44 PM


All times are GMT +1. The time now is 07:53 PM.

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"