R1C1 with dynamic row and column references

runnerpatch3

New Member
Joined
Dec 16, 2011
Messages
3
Hello all,

I am writing a macro to automate bubble charts. I've made one that pulls in the value itself into the chart, but if you go back and change the data, the chart does not update.

Here is an example:
ActiveChart.SeriesCollection(iCounter).XValues = ActiveSheet.Cells(iRowNum, iColNum + 1).Value

But I need it to put in a reference to that cell, not the value itself. Something like this:

ActiveChart.SeriesCollection(iCounter).Name = "=Sheet1!R1C2"

What I really need is the latter along these lines:

ActiveChart.SeriesCollection(iCounter).Name = "=Sheet1!R & iRowNum & C & iColNum"

iRowNum updates based on which row of the data set the loop is in
iColNum is either 0,1,2,3 (name, x-value, y-value, bubble size) but is different based on which field I want to update

The purpose of the macro is to create an empty table with the bubble chart referencing the empty table. And the user can go in and input values into the data table. I have another version that takes a pre-filled table, but I want it this way to ensure that all data tables are set up the same (name, x, y, size INSTEAD OF x,y,size,name....for instance).

Thank you!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi
Welcome to the board

Try:

Code:
ActiveChart.SeriesCollection(iCounter).Name = "=Sheet1!R" & iRowNum & "C" & iColNum
 
Upvote 0
Thank you, that really helps me out. What would be the proper syntax for 'any' sheet? So, instead of:


ActiveChart.SeriesCollection(iCounter).Name = "=Sheet1!R" & iRowNum & "C" & iColNum

Something like....


ActiveChart.SeriesCollection(iCounter).Name = "=[worktab name here]!R" & iRowNum & "C" & iColNum
 
Upvote 0
Hi

Try:

Code:
ActiveChart.SeriesCollection(iCounter).Name = "='" & sSheetName & "'!R" & iRowNum & "C" & iColNum
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,562
Members
449,171
Latest member
jominadeo

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