Find worksheet and import data?
Find worksheet and import data?
(OP)
Hi folks
I need help on loading data from many different workbooks into a different workbook/worksheet so I can analyse the data. All Excel files have the same path, but some workbooks have the specific worksheet others not. The specific worksheets have the same name and the cell range is the same.
E.g.: look for worksheet "W1" on different workbooks; if available, copy the cell range and past on column A, B, C.... (for each data set) on worksheet "summary" of workbook "Data". Row 1 needs to have the workbook name for identification.
Likely this solution is available in this forum, so send me the links so I can start.
Thx
I need help on loading data from many different workbooks into a different workbook/worksheet so I can analyse the data. All Excel files have the same path, but some workbooks have the specific worksheet others not. The specific worksheets have the same name and the cell range is the same.
E.g.: look for worksheet "W1" on different workbooks; if available, copy the cell range and past on column A, B, C.... (for each data set) on worksheet "summary" of workbook "Data". Row 1 needs to have the workbook name for identification.
Likely this solution is available in this forum, so send me the links so I can start.
Thx





RE: Find worksheet and import data?
CODE
Dim curbook As String
Dim myERR As Integer
Dim strFile As String
Dim Counter As Integer
On Error GoTo myERR
curbook = Workbooks(1).Name
Counter = 0
strFile = Dir("F:\My Documents\Worksheets\*.xls")
Do While Len(strFile) > 0
Counter = Counter + 1
If strFile <> curbook Then
Workbooks.Open Filename:=strFile
Sheets("w1").Select
End If
strFile = Dir
Loop
Exit Sub
myERR:
If Err.Number = 9 Then
Workbooks(Counter).Close
Resume Next
End If
End Sub
You will need to change strFile = Dir("F:\My Documents\Worksheets\*.xls") to point to your own directory of course
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
Steam Engine enthusiasts: www.essexsteam.co.uk
RE: Find worksheet and import data?