I am trying to write a Macro to select the active cell from Z$2 and down. I don't want to write a random number at the end since each week I have more or less rows in my table.
For example
"='Table'!$Z$2:$Z$5969" should be like "='Table'!$Z$2:$Z but I get an error
Sub graphtest()
'
' graphtest Macro
'
'
Range("A:A,Z:Z,AF:AF,AI:AI,AJ:AJ").Select
Range("AJ1").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range( _
"'Table'!$A:$A,'Table'!$Z:$Z,'Table'!$AF:$AF,'Table'!$AI:$AI,'Table'!$AJ:$AJ" _
)
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection(1).Values = _
"='Table'!$Z$2:$Z$5969"
ActiveChart.SeriesCollection(1).Name = "='Table'!$Z$1"
ActiveChart.SeriesCollection(2).Values = _
"='Table'!$AF$2:$AF$5969"
ActiveChart.SeriesCollection(2).Name = "='Table'!$AF$1"
ActiveChart.SeriesCollection(3).Values = _
"='Table'!$AI$2:$AI$5969"
ActiveChart.SeriesCollection(3).Name = "='Table'!$AI$1"
ActiveChart.SeriesCollection(4).Values = _
"='Table'!$AJ$2:$AJ$5969"
ActiveChart.SeriesCollection(4).Name = "='Table'!$AJ$1"
ActiveChart.SeriesCollection(4).XValues = _
"='Table'!$A$2:$A$5969"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
" Graph"
End Sub
Bookmarks