N
neilvk
Hi All,
How is it possible to select a data range by using variables?
i.e. instead of range(A:1,c:3) have range(i,j)
Here is my code, the line with the '##### raises an error:
"Invalid or unqualified reference"
'---------------------------------------------------------
Sub Macro2()
iCol = 7
iRow =1
iLeadtime = 5
Worksheets("Sheet1").Activate
Charts.Add
ActiveChart.ChartType = xlLineMarkers
'############
ActiveChart.SetSourceData Source:=Range(.Cells(icol, irow)
.Cells(icol + iLeadtime, irow + 1)).Select, PlotBy:=xlRows
'############
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Stock / Date"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
"Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Stock"
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False
ActiveWindow.Visible = False
End Sub
'---------------------------------------------------------
Many thanks
Nei
How is it possible to select a data range by using variables?
i.e. instead of range(A:1,c:3) have range(i,j)
Here is my code, the line with the '##### raises an error:
"Invalid or unqualified reference"
'---------------------------------------------------------
Sub Macro2()
iCol = 7
iRow =1
iLeadtime = 5
Worksheets("Sheet1").Activate
Charts.Add
ActiveChart.ChartType = xlLineMarkers
'############
ActiveChart.SetSourceData Source:=Range(.Cells(icol, irow)
.Cells(icol + iLeadtime, irow + 1)).Select, PlotBy:=xlRows
'############
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Stock / Date"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
"Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Stock"
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False
ActiveWindow.Visible = False
End Sub
'---------------------------------------------------------
Many thanks
Nei