+ Reply to Thread
Results 1 to 9 of 9

Using Combobox as parameter

  1. #1
    Registered User
    Join Date
    09-01-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    25

    Using Combobox as parameter

    Hi everyone,

    I have a function which has to contain the name of a combo and use it with some given parameters, here's my example:

    Please Login or Register  to view this content.
    I tried this several times but it gives me an error, could you please help me on this one?

    Thank you in advance.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Using Combobox as parameter

    Which error are you getting and what line of the code is it on?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    09-01-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Using Combobox as parameter

    I get Compile Error: Method or Data Member Not Found just before the first line of the Sub.

    Please Login or Register  to view this content.
    I call the combo like this:

    Please Login or Register  to view this content.
    but when I highlight the combo parameter, it gives me:

    cmblist= ""

    Hope this helps.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Using Combobox as parameter

    Unfortunately, I'm not the most familiar with using lists.
    If you could post a sample worksheet without any sensitive information it would be helpful.

  5. #5
    Registered User
    Join Date
    09-01-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Using Combobox as parameter

    Ok, here's my example on the Routines2 sheet, just click on the Show Form button and it will show you how I want to do this. And thanks a lot for your help.
    Attached Files Attached Files

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Using Combobox as parameter

    I'm sorry, I can't use that. Can you save as an excel 03 compatible file?

  7. #7
    Registered User
    Join Date
    09-01-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    25

    Thumbs up Re: Using Combobox as parameter

    Of course. Actually I have figured this out, the problem was that I was calling part of the combo instead of the whole thing, for example:

    I tried to make it work like this
    Please Login or Register  to view this content.
    and the correct way to do it is this
    Please Login or Register  to view this content.
    then on the actual function I had this
    Please Login or Register  to view this content.
    and I tried this, and it worked!
    Please Login or Register  to view this content.
    Now I'm fine with this, nevertheless I appreciate your help. I'm attaching the file (2003 version of course). I didn't realize this was so simple, I'm new at making macros but very open to learn new things on the way.

    Again, Thank you for your support.
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using Combobox as parameter

    Hello Rodas,

    The keyword Me is redundant when referencing objects that belong to the UserForm. It is an undocumented word that seems to have become very popular and overused. There are few times when it can be used effectively, like closing the form...
    Please Login or Register  to view this content.
    Aside from that, you're better off not using it.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Registered User
    Join Date
    09-01-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Using Combobox as parameter

    I agree with you, it can cause some confusion and yes, it is overused. So what you're suggesting is to call an object with it's exact "location"?, like:

    Please Login or Register  to view this content.
    instead of

    Please Login or Register  to view this content.
    Or what would be a shorter, yet efficient way to call the object?

    Thanks in advance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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