+ Reply to Thread
Results 1 to 4 of 4

Return the value of a Combo Box Selection using a Function

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2013
    Posts
    3

    Return the value of a Combo Box Selection using a Function

    Dear All,
    Hope you all are fine. I got a question regarding retrunig of a combobox value using a function.

    I am a userform where I got a combobox and two commmand button. One for cancel and another for OK.

    I have a procedure in which I call the userform with the combobox. When the combobox appears, I will select a value from that combobox and press 'Ok' button and I want that value to be passed to my procedure (basically what I selected from the combobox). I want that value to be returned through a function so that I got 3 more procedures where from I need to call that userform with the combobox again and again.

    Is there any one who can help me out?


    Thanks in advance.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Return the value of a Combo Box Selection using a Function

    Why do you need a function?

    Can't you get the selected value directly from the combobox?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Return the value of a Combo Box Selection using a Function

    I know how to get the value from the combo box. My problem is I want to return that value using a function because my 3 other procedures will be able to use that function's returned value, which will enable me to filter my huge data. It is cumbersome to copy 3 more same userform with same combobox input for 3 procedures. So it would be better to return the value of a combobox and use that value in my different procedures.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Return the value of a Combo Box Selection using a Function

    A function will simply pass the value to whatever Sub it's calling and then it's gone (the function won't hold the value).

    What you need is a variable to which you assign the value of the combobox so you can call it time and time again.
    Attached Files Attached Files
    Last edited by bakerman2; 08-18-2017 at 05:05 AM. Reason: Added example file.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ 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. Poplulating a second combo box based on user selection in first combo box
    By lateniteNC1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2017, 12:40 AM
  2. Replies: 19
    Last Post: 09-06-2014, 06:30 PM
  3. Replies: 8
    Last Post: 12-26-2013, 02:23 PM
  4. [SOLVED] Combo Box2 selections available based on Combo box 1 selection
    By wishn4fishn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2013, 08:13 PM
  5. combo box input range based on the other combo box selection
    By hedayet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2013, 02:27 AM
  6. Populate a Combo Box based on the selection of another Combo Box
    By thunder279 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2011, 03:40 PM
  7. Values of combo box dependent on selection in another combo box
    By vjboaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2008, 05:16 AM

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