FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,368
- Office Version
- 365
- 2016
- Platform
- Windows
Right now I have a data validation box with two choices, Bar or Line. The code below will change the series on the chart which works fine.
I need to now create a groupbox with two optionbuttons inside to control the chart vice the data validation. For the optionbuttons I linked them to a cell (A1) and when clicking on the buttons the cell returns either a 1 or 2.
I'm a little stuck now on how to reference A1 and the value of either a 1 or 2 to change the chart (1 being Bar and 2 Line).
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Set Rng = Target.Parent.Range("I6")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Rng) Is Nothing Then Exit Sub
Select Case Target.Address
Case "$I$6"
With ActiveSheet.ChartObjects("Chart 2").Chart.SeriesCollection(1)
If Range("I6").Value = "Bar" Then
.ChartType = xlColumnClustered
ElseIf Range("I6").Value = "Line" Then
.ChartType = xlLine
.Smooth = True
End If
End With
End Select
End Sub
I need to now create a groupbox with two optionbuttons inside to control the chart vice the data validation. For the optionbuttons I linked them to a cell (A1) and when clicking on the buttons the cell returns either a 1 or 2.
I'm a little stuck now on how to reference A1 and the value of either a 1 or 2 to change the chart (1 being Bar and 2 Line).