Results 1 to 3 of 3

Populating a list box with items from cell

Threaded View

  1. #1
    Registered User
    Join Date
    03-14-2013
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Populating a list box with items from cell

    Hi, just joined today, so really please to be here.

    Hoping someone can help with my question. I have nearly got it right, but not quite.

    I have a userform with1 listbox.

    when the form loads, I have the vba macro look for for all .jpg files in a directory given a certain reference from a cell on the worksheet, for example, 12345

    This works fine.

    MyFolder = Sheets("Main").Range("E15").Value 'I:\pics\
    MyFile = Dir(MyFolder & Sheets("Main").Range("E26").Value) 'I:\pics\12345*.jpg
    Do While MyFile <> ""
        found = found + 1
        filelist.AddItem MyFile
        MyFile = Dir
    Loop
    The above is not a problem as long as there is more than 1 file to find. If it doesn't find any files then it's ok, if it finds more than 1 file it's ok, but if there is only 1 file to find it hangs then crashes.

    Any ideas please?
    Last edited by HikariHitachi; 03-14-2013 at 01:54 PM. Reason: typo and error in post

Thread Information

Users Browsing this Thread

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

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