ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto-Hiding rows based on cell in seperate worksheet (https://www.excelbanter.com/excel-programming/304725-auto-hiding-rows-based-cell-seperate-worksheet.html)

James C[_3_]

Auto-Hiding rows based on cell in seperate worksheet
 
Hello all,

First Special thanks to Dave Peterson for his off-forum help.

The following code does what I want, hiding/unhiding a row based o
whether a cell on another worksheet is blank/non-blank, respectively:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("c5")) Is Nothing Then Exit Sub

On Error GoTo errHandler:
With Target
Application.EnableEvents = False
Worksheets("Trade Output").Range("A6").EntireRow.Hidden
CBool(.Value = "")
End With

errHandler:
Application.EnableEvents = True

End Sub

This code, as you can see, hides/unhides ROW 6 based on c5. I want t
likewise mode ROWS 7 and 8 based on d5 and e5, respctively.

I am still too green in VBA to confidently tweak properly. Any help i
modifying the above code would be great appreciated.

Thanks all,

James

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Auto-Hiding rows based on cell in seperate worksheet
 
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("c5:e5")) Is Nothing Then Exit Sub

On Error GoTo errHandler:
With Target
Application.EnableEvents = False
Worksheets("Trade Output").Range("A6"). _
offset( .Column - 3).EntireRow.Hidden =
CBool(.Value = "")
End With

errHandler:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy


"James C " wrote in message
...
Hello all,

First Special thanks to Dave Peterson for his off-forum help.

The following code does what I want, hiding/unhiding a row based on
whether a cell on another worksheet is blank/non-blank, respectively:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("c5")) Is Nothing Then Exit Sub

On Error GoTo errHandler:
With Target
Application.EnableEvents = False
Worksheets("Trade Output").Range("A6").EntireRow.Hidden =
CBool(.Value = "")
End With

errHandler:
Application.EnableEvents = True

End Sub

This code, as you can see, hides/unhides ROW 6 based on c5. I want to
likewise mode ROWS 7 and 8 based on d5 and e5, respctively.

I am still too green in VBA to confidently tweak properly. Any help in
modifying the above code would be great appreciated.

Thanks all,

James C


---
Message posted from http://www.ExcelForum.com/




James C[_4_]

Auto-Hiding rows based on cell in seperate worksheet
 
thanks muc

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com