I have a macro that works well in merging data from similarly formatted files (each with different data) in a folder. It extracts data from a certain sheet from each file and then merges them into one excel worksheet. I need a change made to this macro and not sure how to do this.
Currently the macro copies all the data from sheet2 in every file, there are only 500 rows of data at the most on every file, I now need it to copy the data in sheet3 only if the value in column C in that sheet is "Speaker Programs" and also I need the value in column A of the corresponding row in sheet2 copied. Following is my current macro
Sub MergeSheets()
Dim SrcBook As Workbook
Dim fso As Object, f As Object, ff As Object, f1 As Object
Dim wkSht As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error GoTo Bye
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.Getfolder("C:\TEMP\4-11\")
Set ff = f.Files
For Each f1 In ff
Set SrcBook = Workbooks.Open(f1)
Sheets(2).Select
Range("A2:J" & Range("b500").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
With Selection
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
SrcBook.Close
End With
Next
Bye:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Any assistance will be highly appreciated.
Thanks,
Michael
Currently the macro copies all the data from sheet2 in every file, there are only 500 rows of data at the most on every file, I now need it to copy the data in sheet3 only if the value in column C in that sheet is "Speaker Programs" and also I need the value in column A of the corresponding row in sheet2 copied. Following is my current macro
Sub MergeSheets()
Dim SrcBook As Workbook
Dim fso As Object, f As Object, ff As Object, f1 As Object
Dim wkSht As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error GoTo Bye
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.Getfolder("C:\TEMP\4-11\")
Set ff = f.Files
For Each f1 In ff
Set SrcBook = Workbooks.Open(f1)
Sheets(2).Select
Range("A2:J" & Range("b500").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
With Selection
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
SrcBook.Close
End With
Next
Bye:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Any assistance will be highly appreciated.
Thanks,
Michael