+ Reply to Thread
Results 1 to 4 of 4

Having a macro recognize when an option button has been selected

  1. #1
    Linking to specific cells in pivot table
    Guest

    Having a macro recognize when an option button has been selected

    Hi,

    I'm trying to an IF THEN statement which is based on which one of two option
    buttons was last selected. I have two option buttons ("OptionButton1" and
    "OptionButton2" -- both from the 'Forms' menu) -- basically I'm trying to
    create a macro that will look at which button is currently selected (this
    button will already have it's radio button showing as being selected) and
    will then execute code specific to which button it finds as being last
    selected. Basically, I want the following:

    'If 'OptionButton1' is slected, then:

    Sheets("2nd Level Sources & Conv").Range("F27").Value = "Equivalent kwh/yr"

    Else

    Sheets("2nd Level Sources & Conv").Range("F27").Value = "Actual kwh/yr"

    End If


    Thanks for your help!

    Rob

  2. #2
    Rowan
    Guest

    RE: Having a macro recognize when an option button has been selected

    You may need to edit the option button name but something like:

    With Sheets("2nd Level Sources & Conv")
    If .OptionButtons("Option Button 1") = 1 Then
    .Range("F27").Value = "Equivalent kwh/yr"
    Else
    .Range("F27").Value = "Actual kwh/yr"
    End If
    End With

    Hope this helps
    Rowan

    "Linking to specific cells in pivot table" wrote:

    > Hi,
    >
    > I'm trying to an IF THEN statement which is based on which one of two option
    > buttons was last selected. I have two option buttons ("OptionButton1" and
    > "OptionButton2" -- both from the 'Forms' menu) -- basically I'm trying to
    > create a macro that will look at which button is currently selected (this
    > button will already have it's radio button showing as being selected) and
    > will then execute code specific to which button it finds as being last
    > selected. Basically, I want the following:
    >
    > 'If 'OptionButton1' is slected, then:
    >
    > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Equivalent kwh/yr"
    >
    > Else
    >
    > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Actual kwh/yr"
    >
    > End If
    >
    >
    > Thanks for your help!
    >
    > Rob


  3. #3
    Linking to specific cells in pivot table
    Guest

    RE: Having a macro recognize when an option button has been select

    Thanks!!

    "Rowan" wrote:

    > You may need to edit the option button name but something like:
    >
    > With Sheets("2nd Level Sources & Conv")
    > If .OptionButtons("Option Button 1") = 1 Then
    > .Range("F27").Value = "Equivalent kwh/yr"
    > Else
    > .Range("F27").Value = "Actual kwh/yr"
    > End If
    > End With
    >
    > Hope this helps
    > Rowan
    >
    > "Linking to specific cells in pivot table" wrote:
    >
    > > Hi,
    > >
    > > I'm trying to an IF THEN statement which is based on which one of two option
    > > buttons was last selected. I have two option buttons ("OptionButton1" and
    > > "OptionButton2" -- both from the 'Forms' menu) -- basically I'm trying to
    > > create a macro that will look at which button is currently selected (this
    > > button will already have it's radio button showing as being selected) and
    > > will then execute code specific to which button it finds as being last
    > > selected. Basically, I want the following:
    > >
    > > 'If 'OptionButton1' is slected, then:
    > >
    > > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Equivalent kwh/yr"
    > >
    > > Else
    > >
    > > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Actual kwh/yr"
    > >
    > > End If
    > >
    > >
    > > Thanks for your help!
    > >
    > > Rob


  4. #4
    William Benson
    Guest

    Re: Having a macro recognize when an option button has been selected

    absolutely unrelated ... but I think you can change your screen name through
    Outlook Express (if that is your reader) by going to Tools-->Accounts-->
    click on MSNews.Microsoft.com and then click Properties and under User
    Information, change the Name there.

    Good Luck.

    Bill.

    ...."We now return you to your regularly scheduled Message Thread"...


    "Linking to specific cells in pivot table"
    <[email protected]> wrote in
    message news:[email protected]...
    > Hi,
    >
    > I'm trying to an IF THEN statement which is based on which one of two
    > option
    > buttons was last selected. I have two option buttons ("OptionButton1" and
    > "OptionButton2" -- both from the 'Forms' menu) -- basically I'm trying to
    > create a macro that will look at which button is currently selected (this
    > button will already have it's radio button showing as being selected) and
    > will then execute code specific to which button it finds as being last
    > selected. Basically, I want the following:
    >
    > 'If 'OptionButton1' is slected, then:
    >
    > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Equivalent
    > kwh/yr"
    >
    > Else
    >
    > Sheets("2nd Level Sources & Conv").Range("F27").Value = "Actual kwh/yr"
    >
    > End If
    >
    >
    > Thanks for your help!
    >
    > Rob




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1