Try something like this, That wasn't the correct way to specify a Range (as you found out)
Note the colon in the .Range
Option Explicit Sub Macro1() Dim L As Long L = 8 Worksheets("Sheet2").Select ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xlXYScatter ActiveChart.SetSourceData Source:=Worksheets("Sheet1").Range("A1:B" & L) End Sub