Run Macro on Cell Change

BMil8

Board Regular
Joined
Aug 9, 2010
Messages
153
Office Version
  1. 365
Hello. I am trying to have a macro run when the value in $C$3 changes. This cell references the grand total in a pivot table on another worksheet that changes when I select different slicer options. I'm able to have this work correctly if I manually change the value in $C$3, but it does not run when that value changes as a result of changing the slicer selections. Is there a way to accomplish this?

Change Event
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$3" Then
Call HideRows
End If
End Sub


HideRows Macro
Sub HideRows()
'
' HideRows Macro
'
Rows("145:251").Select
Selection.EntireRow.Hidden = False
Dim r As Range, c As Range
Set r = Range("C33:a250")
Application.ScreenUpdating = False
For Each c In r
If Len(c.Text) = 0 Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
Application.ScreenUpdating = True
'
End Sub


Thank you
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I did a little digging and it seems that a change event can't be triggered from a formula update so I assume this is the same for a pivot table change. Any idea of a way around this?
 
Upvote 0
Worksheet_Calculate is used for detecting changes from formulas. ;)
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,262
Members
448,880
Latest member
aveternik

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