98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Extracting Data from many worksheets
Extracting Data from many worksheets
Resolved · Medium Priority · Version 2003
Rory has attended:
Excel VBA Intro Intermediate course
Extracting Data from many worksheets
How do you code VBA so that within a particular folder (say C:mydocuments/Excel), open every document in turn and perform the same task on each document. For example if data need to be extracted from many returned forms and all such forms are saved in the same location.
RE: Extracting Data from many worksheets
Thank you for your question.
The command you need is Dir which returns filenames. The first time you use it you specify the location and mask and then you just use dir to find the next match. When dir finds no more files it returns an empty string.
Example
Sub ReportFiles()
Dim FoundFile As String
'Find first file
FoundFile = Dir("c:\reports\*.xls")
Do While FoundFile > ""
Workbooks.Open FileName:="c:\reports\" & FoundFile
' Process each file
'
' Get name of next file
FileName = Dir
Loop
End Sub
Please let me know how you get on.
Laura GB
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Change Excel's default fontYou can change the default font and font size for all spreadsheets created in Excel by: |