+ Reply to Thread
Results 1 to 5 of 5

Using macros to hide options in userform based off prior selections

  1. #1
    Registered User
    Join Date
    05-19-2022
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    11

    Using macros to hide options in userform based off prior selections

    Hello all, I've been writing a code to create a pricing sheet and based off the tool type selected in a userform we offer about 7 of our 15 kinds of coatings along with that tool type. So once a tool is selected I want the non applicable coatings to dissappear from my userform. I've managed to make the coatings dissapear, but if a different tool is then selected, the coatings do not reappear, I was hoping someone might have a couple ideas to make the selected options reappear after deselection, I've tried it 2 different ways, once with a while function which just crashed excel. Any help/ ideas is appreciated, Thanks!
    Here is my code.

    Private Sub OptionButton1_Click()
    OptionButton8.Visible = False
    End Sub

    The second variation that did not work at all

    Private Sub OptionButton1_Click()
    While OptionButton1 = True
    OptionButton8.Visible = False
    Wend
    End Sub
    Last edited by mjlawlor; 06-20-2022 at 09:52 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using macros to hide options in userform based off prior selections

    Impossible to answer without seeing a copy of your workbook - see the yellow banner above for instructions how to upload.

    The one thing that can be said is you 'crashed' excel because it went into an endless loop in the 2nd procedure you listed above. If OptionButton1 has a value of True then there is nothing to either exit the while loop or set OptionButton1 False so it just went around in circles...

  3. #3
    Registered User
    Join Date
    05-19-2022
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Using macros to hide options in userform based off prior selections

    Ok, here you go, the userform named modifiers is the only thing you need to see probably, most of the project is unfinished and unworking. But for a test select Endmill under tool type, and then Altima Plus needs to disappear under Coating, then I need Altima Plus to reappear after Endmill is deselected. Thanks though I figured as much in reference to the loop.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using macros to hide options in userform based off prior selections

    Sometimes it's harder to pose a question than actually answer it ...

    Remove the Click Event for the option button and replace with Change event handler
    Please Login or Register  to view this content.
    Add any other controls that need hiding; however, I'd suggest setting the Enabled property to False instead - no awkward gaps in the list and it's obvious some can't be selected.

    You'll need to repeat for other Tool types but there is a way to have just one procedure to handle all tool types, it just takes a little more coding ...

  5. #5
    Registered User
    Join Date
    05-19-2022
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Using macros to hide options in userform based off prior selections

    Hey, thanks I appreciate the speedy help. Sorry for the unclear posing of my question, I appreciate it though, very helpful!

+ 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. Replies: 0
    Last Post: 06-14-2019, 03:28 PM
  2. Userform ListBox that recalls prior selections made
    By fil_oliveira in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2016, 10:11 PM
  3. [SOLVED] Formula for different options to return a value based upon the selections.
    By jleal in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2014, 04:18 PM
  4. Userform: Can you capture the selections from command buttons and call macros on close
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2013, 06:34 AM
  5. Run different Macros based on what selections have been made in checkbox
    By vetteengr in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-13-2012, 01:13 PM
  6. Hide Rows Based on ListBox Selections
    By gsurge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2011, 02:23 AM
  7. Userform ListBox that recalls prior selections made
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2010, 02:54 PM

Tags for this Thread

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