Named Range for Column?

TimmiT

Board Regular
Joined
Dec 15, 2006
Messages
77
I have a sheet with tabular data. I graph the data, one column per chart on a separate sheet. Since the amount of data changes as a project progresses, I have made a macro to change the amount of data shown:

Code:
'
Dim LR As String
Dim LRV As String
Dim LRR As String

LR = Sheets("Gradation and AC").Range("T1")
LRV = Sheets("VMA").Range("T1")
LRR = Sheets("Test Ranges").Range("w1")

ScreenUpdating = False

Sheets("Charts").ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).XValues = "='Gradation and AC'!$A$18:$A$" & LR
ActiveChart.SeriesCollection(1).Values = "='Gradation and AC'!$F$18:$F$" & LR

Sheets("Charts").ChartObjects("Chart 2").Activate
ActiveChart.SeriesCollection(1).XValues = "='Gradation and AC'!$A$18:$A$" & LR
ActiveChart.SeriesCollection(1).Values = "='Gradation and AC'!$g$18:$g$" & LR

This continues through each of the columns of data. I have coworkers that like to use workbooks that they know nothing about, and love to delete/insert rows and columns. Is there a way to use a named range, that still varies with the data to make this more foolproof?

Also, if a chart is removed, is there an easy way to have the macro skip it vs. encounter an error?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Thanks, I think I can work with that to achieve the missing chart aspects. Anyone have ideas on how to keep the correct data on the chart if a column is added or removed, and still keep the variability of the column length?

Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,726
Messages
6,126,498
Members
449,316
Latest member
sravya

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