Hello Everyone,
I'm trying to write a module that selects a data range for my chart worksheet and changes the title, subtitle, a textbox, and axis labels dependant on button clicks. I have sub routines that select which named range to use based on button clicks and set some of my global variables.
I've already set some global variables and determine rangename in another sub routine by rangename = [MyNamedRange] . rangename is set as a variant right now.
axislabel should be the first column of whatever named range I select.
rng should be a specific column that I select out of the named range (with bank and shift being integers to select that column).
Currently, Im getting held up on defining axislabel, rng, and textbox. I've tried several ways, except for the correct way. This is just the most recent iteration.
Thank you for whatever help you provide.
I'm trying to write a module that selects a data range for my chart worksheet and changes the title, subtitle, a textbox, and axis labels dependant on button clicks. I have sub routines that select which named range to use based on button clicks and set some of my global variables.
I've already set some global variables and determine rangename in another sub routine by rangename = [MyNamedRange] . rangename is set as a variant right now.
axislabel should be the first column of whatever named range I select.
rng should be a specific column that I select out of the named range (with bank and shift being integers to select that column).
Currently, Im getting held up on defining axislabel, rng, and textbox. I've tried several ways, except for the correct way. This is just the most recent iteration.
Thank you for whatever help you provide.
Code:
[TABLE="width: 500"]
<TBODY>[TR]
[TD]Sub SelectDataSeries()
'
'modifies chart to match button selections
'
Dim axislabel As String
Dim rng As String
Dim textbox As String
Dim clmn As Integer
clmn = bank + shift
With rangename
axislabel = offset(1, 1).RefersTo
rng = offset(clmn).Address
End With
textbox = [Text].offset(1, clmn - 1).RefersTo
If title <> "" Then 'prevent null title from deleting chart title
ActiveChart.ChartTitle.Select
selection.Caption = title
End If
ActiveChart.Shapes.range(Array("TextBox 1")).Select
If textbox = "" Then 'prevent null textbox from deleting text box
selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = textbox
Else
selection.Formula = textbox
End If
If subtitle <> "" Then 'prevent null subtitle from deleting subtitle text
ActiveChart.Shapes.range(Array("subtitle")).Select
selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = subtitle
End If
ActiveChart.SeriesCollection(1).Values = rng 'set series 1 to rng
ActiveChart.SeriesCollection(2).Values = rng 'set series 2 to rng
ActiveChart.SeriesCollection(1).XValues = axislabel 'set appropriate axis label
ActiveChart.SeriesCollection(2).XValues = axislabel 'repeat for series 2
ActiveChart.ChartArea.Select
End Sub
[/TD]
[/TR]
</TBODY>[/TABLE]
[TABLE="width: 500"]
<TBODY>[TR]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]