+ Reply to Thread
Results 1 to 7 of 7

Trying to use Selection Box when Input Box is prompted using a Command Button

  1. #1
    Forum Contributor
    Join Date
    05-16-2018
    Location
    Pittsburgh, PA
    MS-Off Ver
    2016
    Posts
    109

    Trying to use Selection Box when Input Box is prompted using a Command Button

    Hello,

    I have been trying to add a selection box to my vba code to use as an option once the user names their category, so the 2nd and 3rd question would prompt up a short list to choose from. (I could just use the input box and have their options listed out, but imagine errors may come from that)

    After taking a stab at it, I have been unsuccessful. Online one states its not possible and then I see other code out their using it. So maybe I am just using it incorrectly and need to call it out another way. Which is where I need help.

    While clicking on the button that would start the vba code, before it starts it highlights the sub name and where it says SelectionBoxSingle and states that the nor the "Sub or Function not defined". Could anyone possibly know the solution?

    I tried creating a new module to call but that didnt work, and I tried using an user form as someone else mentioned but unfamiliar with user forms, so I think I am just using it all wrong and that is why it is not working...

    Please Login or Register  to view this content.
    Thanks,
    Ant
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    SelectionBoxSingle/Multi seems to be from an add-in from the https://www.codeproject.com/tips/872...eraction-with-selectionbox.

    It is not a part of VBA. You should complete your user form (empty now) with an inputbox and at least one combobox with a dynamic list fill range base on the inputbox contents.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    05-16-2018
    Location
    Pittsburgh, PA
    MS-Off Ver
    2016
    Posts
    109

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    @protonLeah or if anyone else has any ideas

    Okay yeah that is what I saw, was not for sure about it.

    But for your comment could you please confirm/clarify: With my current user form, add whatever buttons or detail that is required. And have the user form bring over the data to whatever line? Basically put my input box questions within the user form and use VBA with a command button to open the user form and then have a button inside the form to be the final piece before the line is actually added?

    Also confused by the dynamic list range... assuming something along the lines of the offset function?

    Thanks,
    Ant

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    You could use this userform as a selection input box. The userform has one label, one listbox, and two command buttons
    Please Login or Register  to view this content.
    and it is invoked like an InputBox
    Please Login or Register  to view this content.
    Note that if the MultiSelect is set to true, it returns a delimited string of the selected values.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Contributor
    Join Date
    05-16-2018
    Location
    Pittsburgh, PA
    MS-Off Ver
    2016
    Posts
    109

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    @mikerickson thanks so much for leaving this here. Okay so I am setting this up this morning.

    So once I create my user form with the toolbox adding each of the tools you mention. Then move in the code into the user form.

    But kind of confused by the second piece of code with the list? Does the second piece of code go with the list also go with the other user form code?

    I right clicked on the listbox and view code and added the second piece of code to there, but the list seems not to show up on the user form? However, the first piece of code works with the (what would be the) Ok and Close button on the userform. The userform is shown with a command button on the Balances sheet.

    Attached is an updated file with my explanation.

    Thanks,
    Ant
    Attached Files Attached Files

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    The userform that I made was a stand-alone entity.
    It can be used either directly in a sub or invoked from a userform, just like an InputBox

    In the attached, I renamed it ListChoose and added some features. Pressing Return = clicking OK. Double Click the list = OK. Right click a single select ListChoose and any selection will be cleared.

    The attached file shows two demos of its use. One is through a userform (press the userform button on the worksheet, and then click on any of the label on Userform2). The other button on the sheet runs a test macro that uses the ListChoose directly.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-16-2018
    Location
    Pittsburgh, PA
    MS-Off Ver
    2016
    Posts
    109

    Re: Trying to use Selection Box when Input Box is prompted using a Command Button

    @mikerickson thanks for explaining that, I will take a stab at in the morning to put it all together! Super busy today, but thanks again! Much appreciated.

    Thanks,
    Ant

+ 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. [SOLVED] How to select a option button based on a command button selection and cell value
    By machoman4lyf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2018, 02:19 PM
  2. Command button to request user input (selection) of a range of cells
    By KarlGramith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 05:37 PM
  3. [SOLVED] Command button to reset ComboBox selection
    By Darrenh1238 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2012, 06:14 AM
  4. Command button copy selection to another sheet
    By hlester in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-09-2009, 03:11 PM
  5. Command Button control of Sheet selection
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-13-2009, 05:16 AM
  6. Input Value using Command Button
    By sratkins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2009, 11:39 PM
  7. Data Input Form using Command Button
    By Shooby in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2009, 03:42 AM

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