SetSourceData Function

clearh20

New Member
Joined
Jun 3, 2002
Messages
22
I would like to update the data range in a chart by running a macro. Currently the data range is this "=Parser!$AB$1,Parser!$AB$4:$AB$303,Parser!$AK$1:$AN$1,Parser!$AK$4:$AN$303"

I found that using the following function:"=Parser!$AB$1,OFFSET(Parser!$AB$1:Parser!$AB$1,Parser!$D$2,0,Parser!$B$2,1),Parser!$AK$1:$AN$1,OFFSET(Parser!$AK$1:Parser!$AO$1,Parser!$D$2,0,Parser!$B$2,4)"

I am able to update the data range to the one I want using a different cell as a reference. The problem with this is that the OFFSET function dissappears after entering it. It calculates the value and is done. So if I change the value in my reference cell the data range doesn't update itself.

To avoid this problem I wanted to use a macro that would allow me to click a button and it would update the data range. I would assume that I would use the SetSourceData Function but I don't know how to map the function that I currently have into VB so that it would do the same thing. Any ideas?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
How about using a Dynamic range instead ? using the same OFFSET function you can create one, that will adjust to the value of D2 and B2. Then, all you would need to do is change these two values to change the chart..
 
Upvote 0
I don't think I understand. The source data field in a chart does not allow indirect cell references. Can you explain in more detail what you mean by dynamic? I know what the word means but how do I write a function that will be dynamic using the OFFSET function. That function seems to be a one time only function and does not remain when used in the source data range field.
 
Upvote 0

Forum statistics

Threads
1,218,575
Messages
6,143,313
Members
450,477
Latest member
teresab543

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