+ Reply to Thread
Results 1 to 5 of 5

How to execute a macro when user selects radiobutton

  1. #1
    Registered User
    Join Date
    07-31-2013
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    64

    How to execute a macro when user selects radiobutton

    Hi,

    I have a button named "Convert" that performs some formatting. I have few radio buttons below in which the user can select his option.

    When user selects radiobutton1 and click the Convert button radiobutton1 function should execute. similarly if radiobutton 2 is selected i want that function to excute on clicking the convert button.

    I tried assigning macro to radiobutton it excutes on radio button click.

    But i want it to execute only after clicking on the convert button.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: How to execute a macro when user selects radiobutton

    Try something like the following code (tested using Excel 2003):

    In the UserForm1 code module:
    Please Login or Register  to view this content.
    In an ordinary code module:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-31-2013
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: How to execute a macro when user selects radiobutton

    Thanks. Is it possible to user the optionbutton on cells without the userform

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: How to execute a macro when user selects radiobutton

    No, you can't use 'Option Buttons' on cells without the Userform to the best of my knowledge.

    However, You can SIMULATE 'Option Buttons' by using Shapes, and assign macros to the shapes.
    See the attached workbook written and tested using Excel 2003, which I expanded to 3 Simulated Option Buttons, and uses code very
    similar to what existed with the Userform.


    In the 'ThisWorkbook' module an optional initialization can be used:
    Please Login or Register  to view this content.
    I arbitrarily divided the rest of the code into two modules:
    ModSimulatedOptionButtons - which simulates the Option Buttons and interfaces with the Worksheet.
    ModConvert - which contains code similar the original.

    Code for ModSimulatedOptionButtons follows:
    Please Login or Register  to view this content.
    Code for ModConvert follows:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: How to execute a macro when user selects radiobutton

    I added another sheet to the Workbook, which has 'Shapes' that have the
    look and feel of UserForm Option Buttons. See the attached workbook.

    I did this by adding two Oval 'Shapes' that look like circles for each
    simulated Option Button required. The name of each 'outer circle' is irrelevant.
    The name of each 'inner (filled in) circle' is IMPORTANT because it is used by
    the 'Event Handler' (Macro) to make the 'inner circle' visible or NOT visible.
    I assigned the same Macro to each inner/outer circle pair.

    I had to rename a couple of the 'Shapes' from their original names which looked
    like "Oval 8" to "SimulatedOptionButton1B". The following code is included in
    'ModZTest' in the workbook.

    First I had to identify all the 'Shape' names:
    Please Login or Register  to view this content.

    Then I had to rename the 'inner circle' 'Shapes'.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Quick and Dirty : User selects from dropdown (sht1)...macro populates data from (sht2)
    By Joecruz749 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2013, 05:06 PM
  2. Macro that Selects Specific Excel Worksheets to a PDF file & Saves to the User's Desktop
    By Excel Wet Behind Ear in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2013, 01:15 PM
  3. [SOLVED] Start Macro after user selects a choice from a pick list
    By Mathew in forum Excel General
    Replies: 2
    Last Post: 08-17-2006, 10:30 AM
  4. Record the time a user selects a macro
    By marcusmccown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2006, 10:31 PM
  5. [SOLVED] pause macro until user selects correct range
    By JCIrish in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2006, 05:30 PM

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