PDA

Click to See Complete Forum and Search --> : [Resolved] Populating an xl sheet with the contents of a folder - hmmm?


queenb2005
Apr 20th, 2005, 08:04 AM
:ehh: 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
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

Br1an_g
Apr 20th, 2005, 01:13 PM
are the files all of a particular extension? or mixed types?

Br1an_g
Apr 20th, 2005, 01:19 PM
try this..freehand so may need some amendments



'set start point in spreadsheet
Range("A1").Select

'set directory - you can also set only certain file types
'hence my earlier question
CurrFile = Dir("C:\Directory\*.CSV")
'or use for no particular file type
'CurrFile = Dir("C:\Directory")

'repeat until all file names have been read
Do While CurrFile <> ""

'set value to current cell
activecell = currfile

'offset to next cell in column
activecell.offset(1,0).activate

'set to next file
CurrFile = Dir

Loop

queenb2005
Apr 21st, 2005, 07:45 AM
Thanks Br1an_g! That did the trick. :wave:

~Queen B