Groupbox with optionbuttons

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. 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.

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).
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Okay with some further testing I thought maybe

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range
    Set Rng = Target.Parent.Range("H1")
    If Target.Count > 1 Then Exit Sub
    If Intersect(Target, Rng) Is Nothing Then Exit Sub
    Select Case Target.Value
        Case 1
        MsgBox "You selected option 1"
        Case 1
        MsgBox "You selected option 2"
    End Select
End Sub

but when I change the options within the frame, H1 updates with the 1 or 2, but the macro does not recognize the change.

If I manually change H1 the worksheet change event will fire. How do I get the update of H1 to be recognized on a change event? I tried the calcualte event, but nothing is actually being calculated. It is just a value update.

Any ideas?
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,223
Members
452,896
Latest member
IGT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top