Results 1 to 3 of 3

Excel 2007 : How to select randomly 5 files from a folder/directory

Threaded View

  1. #1
    Registered User
    Join Date
    08-08-2008
    Location
    Johannesburg
    MS-Off Ver
    2007
    Posts
    55

    How to select randomly 5 files from a folder/directory

    Hi Guys
    I'm using this macro to create a list of all files in a specific folder
    Sub BuildListOf_Files_to_Upload()
    
    Extension = "*.jpg"
    Folder = Range("C8").Value '"C:\images folder"
    First = True
    RowCount = 1
    Do
    If First = True Then
    fName = Dir(Folder & "\" & Extension)
    First = False
    Else
    fName = Dir()
    End If
    If fName <> "" Then
    Range("N" & RowCount + 1) = fName
    RowCount = RowCount + 1
    End If
    Loop While fName <> ""
    End Sub
    How can I improve the code so the macro will list 5 files that selected randomly?

    Many thanks for your help.
    Amit.
    Last edited by furiousfox; 11-03-2011 at 02:56 AM. Reason: Solved
    Using Excel 2007.
    Amit Cohen

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