N8theGreat
New Member
- Joined
- Jan 18, 2011
- Messages
- 38
I have 5 sets of data I'd like to be able to display using only one chart that is controlled by a listbox. I've tried a couple of different lines of code and searched to find an appropriate answer for this without any luck. Anyone willing to help?
I could write this code in a module and have it triggered, but I'd like the changes to occur upon input.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$D$1"
If Cells("$D$1") = "Values1" Then
ActiveSheet.ChartObjects("Chart 1").Chart.Activate
ActiveChart.SeriesCollection(1).XValues = Range(Cells(43, 1), Cells(1284, 1))
ActiveChart.SeriesCollection(1).Values = Range(Cells(43, 4), Cells(1284, 4))
End If
If Cells("$D$1") = "Values2" Then
ActiveSheet.ChartObjects("Chart 1").Chart.Activate
ActiveChart.SeriesCollection(1).XValues = Range(Cells(43, 13), Cells(1283, 13))
ActiveChart.SeriesCollection(1).Values = Range(Cells(43, 16), Cells(1283, 16))
End If
Case Else
End Select
End Sub