Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    list of files with common prefix (excel 97)

    <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29> I am stuck trying to work out how I can generate a list of files that all have the same prefix.
    I want the list to appear in the spreadsheet or to be used in some VB code
    All the files are in the one folder

    eg
    the user would type into an inputbox "Mar05"
    and the result would be
    Mar05Costings.xls
    Mar05StaffReport.xls
    Mar05Fabric.xls
    Mar05Orders.xls

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: list of files with common prefix (excel 97)

    Sub ListFiles()
    ' Include trailing backslash
    Const strPath = "C:Excel"

    Dim i As Long

    Dim strFile As String
    strFile = InputBox("Enter first part of file name.")

    strFile = Dir(strPath & strFile & "*.xls")
    Do While Not strFile = ""
    i = i + 1
    Range("A" & i) = strFile
    strFile = Dir
    Loop
    End Sub

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: list of files with common prefix (excel 97)

    works perfectly

    I always learn more than I expect to from your answers.
    thank you very much

Posting Permissions

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