Hi,
I am new to this forum. I am struggeling with creating multiple charts from one set of data in Excel using VBA.
I am able to create my first correct charts by:
Now I would like to replace the hardcoded address-ranges (i.e. "='Sheet1'!$E$3:$E$24") by a dynamic address. At the time my current location on Sheet1 is E3.
For other commands I was able to replace it by:
Range(Selection, Selection.Offset(lastitem-3, 0))
This causes an error message.
Any help would be highly appreciated.
I am new to this forum. I am struggeling with creating multiple charts from one set of data in Excel using VBA.
I am able to create my first correct charts by:
Code:
Set chtChart = Charts.Add
With chtChart
.Name = "ANA_" & Counter1
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=Range("='Sheet1'!$E$3:$E$24"), _
PlotBy:=xlColumns
.HasTitle = True
.ChartTitle.Text = "=ANA_" & Counter1
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "X-Axis"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Y-Axis"
End With
MsgBox "Pause"
ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!$A$4:$A$24"
'Adding new Series
With ActiveChart.SeriesCollection.NewSeries
.Name = Sheets("Sheet1").Range("F3")
.Values = Sheets("Sheet1").Range("F4:F24")
.XValues = Sheets("Sheet1").Range("'Sheet1'!A4:A24")
End With
For other commands I was able to replace it by:
Range(Selection, Selection.Offset(lastitem-3, 0))
This causes an error message.
Any help would be highly appreciated.