Thread: auto hide
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default auto hide

Where are you placing the code?

Worksheet only............original code should work fine.

If you placed it in Thisworkbook module, I screwed up a couple of
things.............apologies.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

should have been

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

And we can't use Me.UsedRange in Thisworkbook since Me refers to
ActiveSheet.

Here is revised code to go into Thisworkbook module

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
'Hide rows with formulas that return negatives
Dim cell As Range
On Error GoTo endit
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(1).SpecialCells(xlCellTypeFormulas)
If cell.Value < 0 Then cell.EntireRow.Hidden = True
Next cell
End With
endit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub


Gord

On Sat, 31 Jan 2009 08:56:01 -0800, Chad
wrote:

When I follow those steps it keeps giving me errors after the with me part.
(.UsedRange
.Rows.Hidden = False)

That is the exact part it is having issue with.
Any ideas again thanks for your help