[Resolved] Populating an xl sheet with the contents of a folder - hmmm?
: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
VB Code:
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
Re: Populating an xl sheet with the contents of a folder - hmmm?
are the files all of a particular extension? or mixed types?
Re: Populating an xl sheet with the contents of a folder - hmmm?
try this..freehand so may need some amendments
VB Code:
'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
Re: Populating an xl sheet with the contents of a folder - hmmm?
Thanks Br1an_g! That did the trick. :wave:
~Queen B