Consulting

Results 1 to 7 of 7

Thread: listbox woes

  1. #1
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location

    listbox woes

    I have a listbox with file names in them. I have another listbox with the complete filenames(Drive Letter\folder\filename) in it. I would like to be able to click the first list box and have the corresponding second list item open. When both are visible (and i move the item of the second) it works. When i hide the second (which is my goal) then it does not get the complete filename. Please help.
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Where do the listboxes get the file names. I can't see the need for two, from what you have described (but I could be wrong!)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    What I want to do is have a file name in a list box. For example one file might be C:\My Documents\Data Files\21002.txt The list box will have only 21002.dat but when the user clicks on the number it opens up the text file. (The files have different locations).
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  5. #5
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    266
    Location
    you could use an array to do that, right?
    if you use the listbox to show the filenames, when user clicks on name the macro finds the complete filename in the array.

    i cant remember what that variable is called, but it tells you what line in the listbox is marked.
    you use that variable to find in the array.

    it should work

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Better to have a two column listbox, with only one visible. Load the first column with the short name, the second with the long name, and when they click, pick up the column two value.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    Yes xld I agree this would be the right idea but what I am stuck on is how to insert and remove a row from a multi-column listbox at will.
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •