Hello all,
I am trying to create a macro using VBA that will automatically run when I update a report filter in my pivot table. My pivot table consists of a bunch of my companies item numbers and the corresponding sales by month. I review our items daily and would like to create a macro that clears values in a range that are then run through some calculations off to the side of the pivot table when I change the displayed item in the report filter.
Currently I am using a macro with a button named "cleardin" to do this for me, but at times I forget to run it and it throws off my final calculation, so I was hoping to create a macro that runs automatically when I change the value in the pivot’s report filter.
I have tried using the below code as an example for my needs, referencing the cell in the report filter as the trigger to clear the values in the range, but haven't had any success as I am very new to VBA.
Any help would be much appreciated, thank you!</SPAN>
I am trying to create a macro using VBA that will automatically run when I update a report filter in my pivot table. My pivot table consists of a bunch of my companies item numbers and the corresponding sales by month. I review our items daily and would like to create a macro that clears values in a range that are then run through some calculations off to the side of the pivot table when I change the displayed item in the report filter.
Currently I am using a macro with a button named "cleardin" to do this for me, but at times I forget to run it and it throws off my final calculation, so I was hoping to create a macro that runs automatically when I change the value in the pivot’s report filter.
I have tried using the below code as an example for my needs, referencing the cell in the report filter as the trigger to clear the values in the range, but haven't had any success as I am very new to VBA.
Code:
Private</SPAN> Sub</SPAN> Worksheet_Change(ByVal</SPAN> Target As</SPAN> Range)
With</SPAN> Target
If</SPAN> .Address = "$b$1" Then</SPAN>
Range("a12:h500").Value = ""
End</SPAN> If</SPAN>
End With</SPAN>
End Sub</SPAN>
Any help would be much appreciated, thank you!</SPAN>