Hi Guys,
I've a chart built out of sales data. There are 3 columns Selection, Category and Sales for year 2001 to 2014.
I need the chart populated dynamically based on the selection column.
I'm using the below code.
Please let me know what I'm doing wrong here. I'm pretty new to VBA and excuse me for any mistakes in syntax.
Sub get_chart_data()
Dim i As Integer
i = 20
For Each i In Sales.Range("B20:B29")
If Sales.Range("B" & i) = "x" Then
Charts("chart1").SetSourceData Source:=Sheets("Sales").Range("C"&i:"Q"&i)
Next i
End Sub
I've a chart built out of sales data. There are 3 columns Selection, Category and Sales for year 2001 to 2014.
I need the chart populated dynamically based on the selection column.
I'm using the below code.
Please let me know what I'm doing wrong here. I'm pretty new to VBA and excuse me for any mistakes in syntax.
Sub get_chart_data()
Dim i As Integer
i = 20
For Each i In Sales.Range("B20:B29")
If Sales.Range("B" & i) = "x" Then
Charts("chart1").SetSourceData Source:=Sheets("Sales").Range("C"&i:"Q"&i)
Next i
End Sub
Last edited: