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


Hi there
I need to hide some columns in excel 2003

example

question in row A1 answer in Row A5
iF THE ANSWER IN a5 is positive then columns d-f must be visible or active
If the answer is negative row D-F should be hidden

My excel knowhow is medium

Any help will be appreciated

Mo


EggHeadCafe - Software Developer Portal of Choice
..NET Remoting - Marshal Objects ByRef
http://www.eggheadcafe.com/tutorials...marshal-o.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Hide columns with certain coditions


This should do it. Assuming of course, you mean by positive and negative =
Yes and No, Respectively. If not then see the second procedure.

Sub hidCol()
Dim sh As Worksheet
Set sh = ActiveSheet
If UCase(sh.Range("A5")) = "NO" Then
Columns("D:F").Hidden = True
Else
Columns("D:F").Hidden = False
End If
End Sub

If you mean numeric negative and positive.

Sub hidCol()
Dim sh As Worksheet
Set sh = ActiveSheet
If sh.Range("A5").Value = 0 Then
Columns("D:F").Hidden = True
ElseIf sh.Range("A5") < 0 Then
Columns("D:F").Hidden = False
Else
MsgBox "The value is not numeric"
End If
End Sub







<moosa Abrahams wrote in message
...
Hi there
I need to hide some columns in excel 2003

example

question in row A1 answer in Row A5
iF THE ANSWER IN a5 is positive then columns d-f must be visible or active
If the answer is negative row D-F should be hidden

My excel knowhow is medium

Any help will be appreciated

Mo


EggHeadCafe - Software Developer Portal of Choice
.NET Remoting - Marshal Objects ByRef
http://www.eggheadcafe.com/tutorials...marshal-o.aspx



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Hide columns with certain coditions


I had the symbols reversed for the numeric version. This corrects it.

Sub hidCol()
Dim sh As Worksheet
Set sh = ActiveSheet
If sh.Range("A5").Value < 0 Then
Columns("D:F").Hidden = True
ElseIf sh.Range("A5") = 0 Then
Columns("D:F").Hidden = False
Else
MsgBox "The value is not numeric"
End If
End Sub




<moosa Abrahams wrote in message
...
Hi there
I need to hide some columns in excel 2003

example

question in row A1 answer in Row A5
iF THE ANSWER IN a5 is positive then columns d-f must be visible or active
If the answer is negative row D-F should be hidden

My excel knowhow is medium

Any help will be appreciated

Mo


EggHeadCafe - Software Developer Portal of Choice
.NET Remoting - Marshal Objects ByRef
http://www.eggheadcafe.com/tutorials...marshal-o.aspx



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Hide columns with certain coditions


This will now give you the message if a non numeric value is entered in A5.

Sub hidCol()
Dim sh As Worksheet
Set sh = ActiveSheet
If Not IsNumeric(Range("A5").Value) Then
MsgBox "The value is not numeric"
ElseIf sh.Range("A5").Value < 0 Then
Columns("D:F").Hidden = True
ElseIf sh.Range("A5").Value = 0 Then
Columns("D:F").Hidden = False
End If
End Sub

I overlooked the fact that an alpha character is considered by VBA to be a
value greater than a numeric character and therefore, greater than zero.


<moosa Abrahams wrote in message
...
Hi there
I need to hide some columns in excel 2003

example

question in row A1 answer in Row A5
iF THE ANSWER IN a5 is positive then columns d-f must be visible or active
If the answer is negative row D-F should be hidden

My excel knowhow is medium

Any help will be appreciated

Mo


EggHeadCafe - Software Developer Portal of Choice
.NET Remoting - Marshal Objects ByRef
http://www.eggheadcafe.com/tutorials...marshal-o.aspx



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/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
Cannot Hide Columns Joe A Excel Discussion (Misc queries) 2 December 15th 04 10:22 PM


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