Solved

Option buttons in Excel

Posted on 2014-04-13
3
353 Views
Last Modified: 2014-04-13
Folks,
I have three option buttons on the form below. When the user click on "Selected Worksheet" they need to go to the worksheet selected. My option buttons are optOne, optTwo, optThree.
The option buttons came from the Tools for the form when I inserted a UserForm. I plan on incorporating a message box to affirm that what the user select was what they wanted.
I've named the command button "cmdWorksheet"
Program optin buttons
0
Comment
Question by:Frank Freese
3 Comments
 
LVL 26

Assisted Solution

by:MacroShadow
MacroShadow earned 250 total points
Comment Utility
Private Sub cmdWorksheet_Click
    Dim strSheetName as String
    Select Case Me.OptionGroup
        Case Is = "optOne"
            strSheetName = "Expected Delivery Date"
        Case Is = "optTwo"
            strSheetName = "Vaccines"
        Case Is = "optThree"
            strSheetName = "Filters"
    End Select
    Worksheets(strSheetName).Activate
End Sub
0
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 250 total points
Comment Utility
I believe this is what you are looking for... Choose the sheet name with your sheet names also choose what optionbutton name you have defined...

Private Sub cmdWorksheet_Click()
    Dim resp As String
    If OptionButton1.Value = True Then
        resp = MsgBox("Do you want to select Sheet1?", vbYesNo)

        If resp = vbYes Then
            Sheets("Sheet1").Select
        Else
            MsgBox "Option Canceled"
        End If
    End If

    If OptionButton2.Value = True Then
        resp = MsgBox("Do you want to select Sheet2?", vbYesNo)

        If resp = vbYes Then
            Sheets("Sheet2").Select
        Else
            MsgBox "Option Canceled"
        End If
    End If


    If OptionButton3.Value = True Then
        resp = MsgBox("Do you want to select Sheet3?", vbYesNo)

        If resp = vbYes Then
            Sheets("Sheet3").Select
        Else
            MsgBox "Option Canceled"
        End If
    End If


End Sub

Open in new window


Saurabh...
0
 

Author Closing Comment

by:Frank Freese
Comment Utility
Fantastic - thank you both very much
I do appreciate all that the Experts do in helping me!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now