Auto Hiding and Unhiding Rows

SONART

New Member
Joined
Aug 18, 2010
Messages
43
Hi,

I'm just a novice when it comes to VBA.

I have picked up a macro online but it needs tweaking to auto hide and unhide rows with 0 values.

The macro highlighted in green works and enables me to select values from a drop down list which drives my derived data set.

I'm trying to link a macro to auto hides and unhides rows with 0 in column A, triggered when selecting from the drop down list.
I also want the macro to default or reset to a starting point (A23) and looks at column A, auto hide/unhide the rows with 0 value.

The macro below (highlightred in red) appears to half work but it appears it doesn't reset to A23 before running the command and I think it's driven by keying in 0 to a cell range. I want the macro to be automated when selecting from a drop down value (target row 13 and column 13).

Could someone please help.

Thanks in advance,
SONART

Private Sub Worksheet_Change(ByVal Target As Range)

' Command below to stop it from flickering
Application.ScreenUpdating = False
If Target.Row = 13 And Target.Column = 13 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("UNIQUE").Range("G4").Calculate
Worksheets("UNIQUE").Range("BRK_UNIQUE") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("UNIQUE").Range("G3:G4"), _
CopyToRange:=Sheets("UNIQUE").Range("O8:T8"), Unique:=True

End If

Dim rngData As Range, rngCell As Range, xlCalc As XlCalculation
Set rngData = Range("A23:A82")
If Not Intersect(Target, rngData) Is Nothing Then
With Application
xlCalc = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
For Each rngCell In rngData.Cells
rngCell.EntireRow.Hidden = rngCell.Value = 0
Next rngCell
.Calculation = xlCalc
.ScreenUpdating = True
.EnableEvents = True
End With
End If
Set rngData = Nothing
End Sub
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

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