Okay guys, I need some serious help here!!!!
Here is what I'm looking for, I have several workbooks that I need to import into just ONE workbook. I found some code that imports the workbooks into the ONE workbook, but it creates multiple worksheets of the same name. For instance, Human Resources(1), Human Resouces(2). Well, that's not quite what I need. I need to have the data from a particularlly named worksheet (for example, Human Resources) from multiple workbooks, which have been created using a template with the different named worksheets. I need the data from the multiple workbooks to be copied into just ONE worksheet of the same worksheet name in that ONE workbook. The following code is what brings the data into multiple worksheets of the same name, but this is NOT what i need...PLEASE HELP!
'Opens the selected files
Workbooks.Open filenames(counter)
strSourceDataFile = ActiveWorkbook.Name
If strSourceDataFile <> strActiveBook Then
Set allwShts = Worksheets
For Each wSht In allwShts
Workbooks(strSourceDataFile).Activate
If wSht.Visible = True Then
Sheets(wSht.Name).Select
Sheets(wSht.Name).Copy before:= _
Workbooks(strActiveBook).Sheets(1)
Sheetname = Left(strSourceDataFile, Len(strSourceDataFile) - 4)
Workbooks(strActiveBook).Activate
'Check to see if a Sheet already has the name
If SheetExists(Sheetname) = True Then
ActiveSheet.Name = Left(strSourceDataFile, Len(strSourceDataFile) - 4) & "(" & wSht.Index & ")"
Else
ActiveSheet.Name = Left(strSourceDataFile, Len(strSourceDataFile) - 4)
End If
End If
Next wSht
Thanks a bunch
Here is what I'm looking for, I have several workbooks that I need to import into just ONE workbook. I found some code that imports the workbooks into the ONE workbook, but it creates multiple worksheets of the same name. For instance, Human Resources(1), Human Resouces(2). Well, that's not quite what I need. I need to have the data from a particularlly named worksheet (for example, Human Resources) from multiple workbooks, which have been created using a template with the different named worksheets. I need the data from the multiple workbooks to be copied into just ONE worksheet of the same worksheet name in that ONE workbook. The following code is what brings the data into multiple worksheets of the same name, but this is NOT what i need...PLEASE HELP!
'Opens the selected files
Workbooks.Open filenames(counter)
strSourceDataFile = ActiveWorkbook.Name
If strSourceDataFile <> strActiveBook Then
Set allwShts = Worksheets
For Each wSht In allwShts
Workbooks(strSourceDataFile).Activate
If wSht.Visible = True Then
Sheets(wSht.Name).Select
Sheets(wSht.Name).Copy before:= _
Workbooks(strActiveBook).Sheets(1)
Sheetname = Left(strSourceDataFile, Len(strSourceDataFile) - 4)
Workbooks(strActiveBook).Activate
'Check to see if a Sheet already has the name
If SheetExists(Sheetname) = True Then
ActiveSheet.Name = Left(strSourceDataFile, Len(strSourceDataFile) - 4) & "(" & wSht.Index & ")"
Else
ActiveSheet.Name = Left(strSourceDataFile, Len(strSourceDataFile) - 4)
End If
End If
Next wSht
Thanks a bunch