VBA Hide Rows In A Table Based on Conditions

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
===============================================
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
please give me the data area or just send the xls file to my mailbox :yunzzy@gmail.com,I will help you to solve the problem~
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top