View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
vezerid
 
Posts: n/a
Default automatically hide row if cell contains asterisk


Hi Hubitron

What you are requesting is trickier, since the values change from
formulas. The following event macro traps the Calculate event and
performs what you ask with Sheet3 (change as necessary in the code).

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Dim col As Range
r = Sheets("Sheet3").UsedRange.Rows.Count
Application.EnableEvents = False
For i = 1 To r
If Sheets("Sheet3").Range("B" & i).Value = "" Then
Sheets("Sheet3").Range("B" & i).EntireRow.Hidden = True
Else
Sheets("Sheet3").Range("B" & i).EntireRow.Hidden = False
End If
Next i
Application.EnableEvents = True
End Sub

There are times that you might curse such automation. If this is the
case you will have to delete this macro.

To install (and delete later):
Alt+F11 to go to the VBA editor
Ctrl+R to toggle display of the Project Manager
Select your workbook and double click the ThisWorkbook icon
Paste the code above.

HTH
Kostis Vezerides
Hubitron2000 Wrote:
Hi, vezerid. I'm trying to do something similar to djarcadian. How
exactly
does one use the Worksheet_Change macro?

My goal is to hide rows if they contain a blank in Column B and to
unhide
them as soon as Column B becomes nonblank. The cells in Column B are
formulas
which take their value from a different worksheet.

Suggestions?

"vezerid" wrote:

djarcadian

IF what you want is to hide the row as soon as an asterisk is

entered,
then you need to use the Worksheet_Change macro.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "*" Then
Target.EntireRow.Hidden = True
End If
End Sub

Does this work for you?

Kostis Vezerides




--
vezerid
------------------------------------------------------------------------
vezerid's Profile: http://www.excelforum.com/member.php...o&userid=28481
View this thread: http://www.excelforum.com/showthread...hreadid=513775