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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
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..
 

clearh20

New Member
Joined
Jun 3, 2002
Messages
22
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.
 

Forum statistics

Threads
1,181,580
Messages
5,930,718
Members
436,757
Latest member
Marijn

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
Top