Results 1 to 4 of 4

Thread: [Resolved] Populating an xl sheet with the contents of a folder - hmmm?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    12

    Resolved [Resolved] Populating an xl sheet with the contents of a folder - hmmm?

    Ok I am trying to macro a process that takes all files from a folder and lists them in column A of an Excel sheet. From there I will make a second process to open them in sequence and run other processes with them, but I got that part in the bag. I'm just having trouble on where to begin. I know I have to
    VB Code:
    1. ChDir ("\\myserver\blah\blahblah\mydir\")
    then I draw a blank. It's probably so easy it's hard. If anyone has any input I'd greatly appreciate it.

    ~QueenB
    Last edited by queenb2005; Apr 21st, 2005 at 07:46 AM. Reason: Resolved issue

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Populating an xl sheet with the contents of a folder - hmmm?

    are the files all of a particular extension? or mixed types?
    if you fail to plan, you plan to fail

  3. #3
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Populating an xl sheet with the contents of a folder - hmmm?

    try this..freehand so may need some amendments

    VB Code:
    1. 'set start point in spreadsheet
    2. Range("A1").Select
    3.  
    4. 'set directory - you can also set only certain file types
    5. 'hence my earlier question
    6. CurrFile = Dir("C:\Directory\*.CSV")
    7. 'or use for no particular file type
    8. 'CurrFile = Dir("C:\Directory")
    9.  
    10. 'repeat until all file names have been read
    11. Do While CurrFile <> ""
    12.  
    13. 'set value to current cell
    14. activecell = currfile
    15.  
    16. 'offset to next cell in column
    17. activecell.offset(1,0).activate
    18.  
    19. 'set to next file
    20. CurrFile = Dir
    21.  
    22. Loop
    if you fail to plan, you plan to fail

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    12

    Re: Populating an xl sheet with the contents of a folder - hmmm?

    Thanks Br1an_g! That did the trick.

    ~Queen B

Posting Permissions

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



Click Here to Expand Forum to Full Width