+ Reply to Thread
Results 1 to 5 of 5

macro to open userform1 turn optionbox1 to true and click commandbutton1

  1. #1
    Forum Contributor
    Join Date
    01-27-2015
    Location
    New hampshire
    MS-Off Ver
    excel 2013
    Posts
    143

    macro to open userform1 turn optionbox1 to true and click commandbutton1

    how would I code this? thank you

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: macro to open userform1 turn optionbox1 to true and click commandbutton1

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-27-2015
    Location
    New hampshire
    MS-Off Ver
    excel 2013
    Posts
    143

    Re: macro to open userform1 turn optionbox1 to true and click commandbutton1

    thanks for the reply! but the form can also me opened manually so I can have it automatically click that button.. is the a way to have this done without having it do this when the form Initializes?

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

    Re: macro to open userform1 turn optionbox1 to true and click commandbutton1

    Hi Jenkins27,

    See the attached file and the code below which is included in the file. Please note that OptionButtons are usually placed in a Group, to allow more than one set of OptionButtons on a UserForm.

    There is more than one way to accomplish what you want.

    Please note that in both cases the CommandButton Event Handler gets activated before the UserForm is displayed.

    There are two ways to display a UserForm, Modal (which locks out all Excel Resources) and nonModal or Modeless (which allows Excel resources to be accessed).

    When a UserForm is loaded as Modal, macro execution is paused at the line that loads the UserForm. Execution continues when the '.Hide' or the 'Unload' command is executed. That is why the UserForm commands are before the .Show command in Sub DisplayUserForm2NormalRuntimeUsage().

    When a UserForm is loaded as NonModal, macro execution continues after the .Show command.


    The commands for each are displayed here:
    Please Login or Register  to view this content.

    ------------------------
    In the first case (UserForm1), the heavy lifting is done by UserForm_Initialize() which is automatically called when the UsefForm is loaded (.show) command.

    UserForm1 module code:
    Please Login or Register  to view this content.
    Ordinary Module code:
    Please Login or Register  to view this content.
    ------------------------
    In the second case (UserForm2), the ordinary module code sets the values before the UserForm is loaded.

    UserForm2 module code:
    Please Login or Register  to view this content.
    Ordinary Module code:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-27-2015
    Location
    New hampshire
    MS-Off Ver
    excel 2013
    Posts
    143

    Re: macro to open userform1 turn optionbox1 to true and click commandbutton1

    thank you!! that's great!!

+ 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. Opening a UserForm1 With Workbook Hidden To allow Other Excel Docs to open normally
    By chrisandsally in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2015, 11:28 AM
  2. Open excel file on every Sunday at 23:00 hrs and activate commandbutton1 vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-04-2015, 05:03 PM
  3. How do you open UserForm1 with a checkbox?
    By JustinMAS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2008, 01:57 PM
  4. [SOLVED] UserForm1.show fails if another workbook is open
    By gary in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2006, 11:21 AM
  5. [SOLVED] Userform1-Can I override the need to click on the form?
    By sbweid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2005, 04:06 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