Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Anthony Fantone
 
Posts: n/a
Default How Do I Hide A Row (if a condition is true) using a Macro ?

I'm using MS Office Excel 2003.

I have a spreadsheet with a series of cells that require an input of (Y)es,
(N)o or (H)ide. If the user enters an "H" for hide I want that entire row to
Hide. Is there a Macro I can use to make this happen.

Also, I would need a switch at the top of the spreadsheet that would allow a
user to enter a "U" for "Unhide" so that all hidden rows could be "U"nhidden
and visable again. Is there a Macro I can use to make this happen also ?

Thank You for your help.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

This works on H1:H10, adjust to suit

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
If .Value = "H" Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"Anthony Fantone" <Anthony wrote in
message ...
I'm using MS Office Excel 2003.

I have a spreadsheet with a series of cells that require an input of

(Y)es,
(N)o or (H)ide. If the user enters an "H" for hide I want that entire row

to
Hide. Is there a Macro I can use to make this happen.

Also, I would need a switch at the top of the spreadsheet that would allow

a
user to enter a "U" for "Unhide" so that all hidden rows could be

"U"nhidden
and visable again. Is there a Macro I can use to make this happen also ?

Thank You for your help.



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 to hide section of worksheet based on a condition (e.g. tick . kitepuppet Excel Discussion (Misc queries) 2 March 4th 05 07:30 PM
Building list based on condition Henrik Excel Worksheet Functions 3 January 26th 05 08:26 AM
How do I hide a column based on a condition (option not available. jgentillet Excel Worksheet Functions 0 January 24th 05 03:53 PM
Grand Totals @ Same Place Amber M Excel Worksheet Functions 2 December 30th 04 08:13 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 08:16 PM


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