03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I found this code on one of the Mr. Excel threads and it is really close to what I am looking for, I think:
I have a table setup called SCTable that contains many fields. I am using this table for generating a graph. The problem is that it contains some blank rows and I would like the blank rows hidden automatically if the field [Net Prod] is = 0.
If cell E5 changes which contains a date for the report, this would trigger the macro. Since this report can run for any days, I would also like to hide any rows where [Date] is after the date entered in E5, that way the graph is accurate.
Any help you can give is greatly appreciated.
Here is the code I found that is really close except it hides specific columns and I need to hide rows that meet the conditions above.
=================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim keyRange As Range
Set keyRange = Range("AC2")
On Error Resume Next
Set keyRange = Application.Union(keyRange, keyRange.Precedents)
On Error GoTo 0
If Not Application.Intersect(keyRange, Target) Is Nothing Then
With Range("13:15").EntireRow
If Range("AC2") = 1 Then
.Hidden = True
ElseIf Range("AC2") = 1 Then
.Hidden = False
End If
End With
End If
End Sub
===============================================
I have a table setup called SCTable that contains many fields. I am using this table for generating a graph. The problem is that it contains some blank rows and I would like the blank rows hidden automatically if the field [Net Prod] is = 0.
If cell E5 changes which contains a date for the report, this would trigger the macro. Since this report can run for any days, I would also like to hide any rows where [Date] is after the date entered in E5, that way the graph is accurate.
Any help you can give is greatly appreciated.
Here is the code I found that is really close except it hides specific columns and I need to hide rows that meet the conditions above.
=================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim keyRange As Range
Set keyRange = Range("AC2")
On Error Resume Next
Set keyRange = Application.Union(keyRange, keyRange.Precedents)
On Error GoTo 0
If Not Application.Intersect(keyRange, Target) Is Nothing Then
With Range("13:15").EntireRow
If Range("AC2") = 1 Then
.Hidden = True
ElseIf Range("AC2") = 1 Then
.Hidden = False
End If
End With
End If
End Sub
===============================================