Discussion Locked

vbXL - copying from multiple w/books

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I need to copy line 2 from every spreadsheet in a directory. I have control of the spreadsheet design but no control of its name nor do I know how many spreadsheets there will be in the directory. I have the copying routine down but need the for..next concept

1 reply

by jscragg

Private Sub EnumerateFolder(strFolderPath)
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFiles As Scripting.Files
Dim objFile As Scripting.File

Set objFSO = New Scripting.FileSystemObject
Set objFolder = objFSO.GetFolder(strFolderPath)
Set objFiles = objFolder.Files

For Each objFile In objFiles
' This will enumerate the collection of files
' found in the specified folder.
' Do your work here.
Next objFile
End Sub

This discussion is closed to new replies.