Value To Cell Based On Option Button

  • New user - hope this works out:

    I'm trying to use option buttons to create a text entry in an adjacent cell.
    Selecting Option Button 1 puts "GPM" in cell F23
    Selecting Option Button 1 puts "lbm/hr" in cell F23
    (The option buttons are from the control toolbox)

    I receive ""Run-time error '424': Object Required"" and first line is highlighted- here is copy of code:

    Thanks for any help that can be provided - I have found a lot of helpful information on this site already.

  • Re: Option Button Creates Text

    The first line should be something like

    If Sheet1.OptionButton1.Value Then

    ... where Sheet1 is the CodeName (see VBA Help) of the sheet where the button appears.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Option Button Creates Text

    ..or paste the original code in the sheet's code module instead (right clickthe tab and choose 'view code' and paste it there).

    ..or while in design mode, double click the option button to get you automatically to the click event code for that button, add one line each time ending up with:

    Private Sub OptionButton1_Click()
    Range("F23") = "GPM"
    End Sub
    Private Sub OptionButton2_Click()
    Range("F23") = "lbm/hr"
    End Sub

    ps. in both cases, I've assumed that the option buttons and F23 are on the same sheet.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!