+ Reply to Thread
Results 1 to 13 of 13

Run different Macros based on what selections have been made in checkbox

  1. #1
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    5

    Run different Macros based on what selections have been made in checkbox

    Hi,
    I am creating a BoM table. There are different option content for the product. I have a set of checkbox (Form) that I have on the first tab. For instance, the product can have
    1. 7.6Kwh
    2. 15 Kwh
    3. 23 Kwh

    the second set of options are:
    1. HVAC
    2. Heater Only

    the third set of options are:
    1. Red
    2. White
    3. Blue

    I have separate tabs for each of these option sets and I have created a blank template sheet. I want the macro to populate the blank template based on the selection made on the first page. For instance, if I select 7.6, Heater and White, I want the macro to copy the info from those 3 tabs and paste them in the blank template.

    Can this be done? Appreciate the help...

  2. #2
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Run different Macros based on what selections have been made in checkbox

    Assuming the data you populate the 3rd sheet with comes from the other tabs for each option an example spreadsheet would facilitate a detailed response.
    It certainlyy sounds simple enough.

  3. #3
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Run different Macros based on what selections have been made in checkbox

    Hi Brynbaker,
    Thanx for the response. Yes, the data are in different tabs. I am attaching the file for your review. I plan on showing only the "Welcome" and the "BoM" tabs to the users. They will select the options they want from the Welcome screen and when they click the command button I want it to run the macros based on the selections made.

    Thank you again.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Run different Macros based on what selections have been made in checkbox

    Apologies for the delay; this PC has Office 2010 but rejects downloads from the forum; my home PC has 2003. I have another option that I will try as soon as possible.

  5. #5
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Run different Macros based on what selections have been made in checkbox

    Quote Originally Posted by brynbaker View Post
    Apologies for the delay; this PC has Office 2010 but rejects downloads from the forum; my home PC has 2003. I have another option that I will try as soon as possible.
    Hi Brynbaker,
    Appreciate your help. Looking forward to your comments.

  6. #6
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Run different Macros based on what selections have been made in checkbox

    I had not forgotten, but I have been thwarted in my attempt: A major domestic upheaval has mislaid (I hope that's the right word) my laptop. I hav unable
    Incidentally it may be time to update your details; the stuff at left of your posts says 2003 but you've uplaoded a .xslx file? I have managed to load part in 2003 and it may be enough though the conversion listed 4 problems. Before I get timed out I will pause and read what i loaded...

  7. #7
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Run different Macros based on what selections have been made in checkbox

    Hmm. Well I see that you have used the macro recorder to develop some of the code - right on! More people should try that. But it's wise to read and tidy what you get, eliminating the unnecessary (for example spurious "Ramg3("A6".Select") when you click a cell you don't really need to while recording.
    Anyway it is a bit hard to follow. And I don't use userforms (mo-one has shown me any advantage in simple design). But I do know that options usually require an option button so that (for instance) one cannot order a car that both has and ddoes not have a heater!

    Apart from these slim pieces of advice, I think the issue about loading the unconverted file in the correct Excel version prevents me from helping you further at present. I hope another member is better placed to help. I will monitor the thread in case I can do more.

  8. #8
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Run different Macros based on what selections have been made in checkbox

    Hi,
    Thank you for your comments. Yes, i mostly used the recorder and a bit of help from other members to create some of the VB. I can save the file in a earlier format if that helps. Appreciate any help.

    Regards

  9. #9
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Run different Macros based on what selections have been made in checkbox

    And I apologize, my Excel is Excel 2010

  10. #10
    Forum Contributor
    Join Date
    06-27-2006
    Posts
    310

    Re: Run different Macros based on what selections have been made in checkbox

    I also have 2003, so I cannot view your file.
    But in general your code will be a lot more straightforward if you use listboxes for those choices.
    I would also ask why you have separate tabs for those options.

  11. #11
    Forum Contributor
    Join Date
    06-27-2006
    Posts
    310

    Re: Run different Macros based on what selections have been made in checkbox

    Here is a code example of how you might handle that with 3 groups of option buttons (instead of check boxes) on the same tab

    Create 3 option buttons named wattage_1, wattage_2,wattage_3
    Set the value of wattage_1 = true
    Give them all the same group name. (ex wattage)
    The name won't matter

    Create 2 option buttons named type_1, type_2 (for hvac or heater)
    Set the value of type_1 = true
    Give those two the same group name (ex type)

    Create 3 option buttons named color_1, color_2,color_3
    Set the value of color_1 = true
    Give them all the same group name. (ex color)

    Put a control button on the form
    Use this code
    Please Login or Register  to view this content.
    When you hit the command button (call it the enter button) you'll have the wattage, type and color variables available in your code.
    Last edited by SuitedAces; 11-13-2012 at 02:39 AM.

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Run different Macros based on what selections have been made in checkbox

    Hi vetteengr

    I've taken the liberty of rewriting the code for Sub Battery7_6Kwh() and Sub Battery15Kwh().

    Sub Battery7_6Kwh() is assigned to Check7-6 and Sub Battery15Kwh is assigned to Check Box 2. The respective Code will run when the Check Box is clicked.

    Let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  13. #13
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Run different Macros based on what selections have been made in checkbox

    John thanks for your input. I diid look up Atwood Lake: very nice. I'm jealous.

+ 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