Run Macro on Data Refresh

AlabasterShelf

New Member
Joined
Jun 20, 2014
Messages
5
Hello all,

I have a worksheet that autorefreshes every five minutes. I also have a macro that reformats the range of a chart based on the value of a given cell D1. The value of D1 may change after the autorefresh. I'm very very new to VBA so please bear with me. I tried one bit of code (see below).

Public Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$1" Then
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).MaximumScale = Worksheets("Summary RYG").Range("D1").Value
End If
End Sub

D1 is set to reference another cell in the worksheet and is an "=XXX" set up instead of an actual number. The program will not trigger if the value of that cell changes from the autorefresh. It will only trigger if I manually retype or re-assign the value of that cell, which defeats the purpose of automation.

If anybody could help me out altering this code, or figuring out some new code, I'd really appreciate it. Thank you in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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