Setting a chart source data based on a variable cell range in VBA

后端 未结 1 1377
北恋
北恋 2020-12-11 18:26

I am creating a report template part of which will be generating data charts with a structure similar to a moving average

for this I need to select a range of data i

相关标签:
1条回答
  • 2020-12-11 19:14

    You have to fully qualify the .Cells object

    Try this

    ActiveChart.SetSourceData Source:=Sheets("Weekly Trends").Range(Sheets("Weekly Trends").Cells(x, y), Sheets("Weekly Trends").Cells(k, Z))

    You can also make the above code short

    With Sheets("Weekly Trends")
        ActiveChart.SetSourceData Source:=.Range(.Cells(x, y), .Cells(k, Z))
    End With
    
    0 讨论(0)
提交回复
热议问题