+ Reply to Thread
Results 1 to 6 of 6

Call ListBox through variable

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Call ListBox through variable

    hi,

    do you know if there is the chance to call a Listbox in a Userform trough a variable?
    I was thinking about something like this:

    x = "Listbox1"
    With UserForm1.x
    ...
    End With

    Thanks!

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Call ListBox through variable

    I'm not 100% positive because lists boxes behave differently in VBA then they do in VB.Net but I believe you have to loop through all items in your listbox checking the IF the selected propert = true then x = selected item index number.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Call ListBox through variable

    Hi,

    Maybe I wasn't clear in asking the question. I know how to handle the items in the listbox. The problem is that I want to "call" the Listbox through a variable.
    I hope like this is more clear:

    Please Login or Register  to view this content.


    Thank you

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Call ListBox through variable

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Call ListBox through variable

    Works fine.

    Thanks

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Call ListBox through variable

    simply
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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. Call a userform from a listbox selection
    By seanpears99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2013, 03:49 AM
  2. Call a constant/variable by creating another variable
    By pienaaj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2013, 10:36 AM
  3. Call macro if specific text is within listbox
    By EthanM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2011, 12:00 AM
  4. According to the criteria you want to call the data listbox
    By ersoyalanprovus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2009, 05:15 AM
  5. Call function to fill Listbox
    By ingineu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2006, 08:13 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