Hi, I have four excel files with the same number of worksheets (four) in the same order and with the same names. I only want sheet2 and sheet3 to be merged into another workbook that has the same format as the others. I got a macro from this board copying all the worksheets into one workbook under respected worksheets.
The code I included is the cycling of the worksheets and what I think needs modification is the line:
so that it only deals with sheet2 and sheet3 instead of every worksheet in the workbooks. The only problem I have I have no idea on how to do that.
I tried using an If statement with GoTo to skip the copying process when the sheet name is what I want to skip, but I couldn't get it to work... Thanks in advance.
The code I included is the cycling of the worksheets and what I think needs modification is the line:
Code:
For Each w In ActiveWorkbook.Worksheets
I tried using an If statement with GoTo to skip the copying process when the sheet name is what I want to skip, but I couldn't get it to work... Thanks in advance.
Code:
On Error Resume Next
For x = 1 To 4
For Each w In ActiveWorkbook.Worksheets
v = w.Name
If Application.CountA(w.Columns(1)) = 1 Then
Alr = 2
Else
Alr = w.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
End If
If Application.CountA(ThisWorkbook.Worksheets(v).Cells) <> 0 Then
Tlr = ThisWorkbook.Worksheets(v).Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Else
Tlr = 1
End If
w.Rows("2:" & Alr).Copy ThisWorkbook.Worksheets(v).Cells(Tlr, 1)
Next w
ActiveWorkbook.Close False
Next x