Jagdev Singh
Active Member
Hi Experts
I have the below code which merge data from 2 sheets in the same workbook into one sheet. It works perfectly fine in most of the instances, but throw errors when I filter the data from 2 sheets and then run the code.
The code throws error at this juncture
Is there any issue if we filter the data in the sheet and then try to run this code. Is there any turn-around to deal with this issue.
Regards,
JD
I have the below code which merge data from 2 sheets in the same workbook into one sheet. It works perfectly fine in most of the instances, but throw errors when I filter the data from 2 sheets and then run the code.
Code:
Sub MergeSheets()
Application.ScreenUpdating = False
Sheets("Merge").Select
Rows("2:" & Rows.Count).ClearContents
Sheets("Client").Select
Range("A2:X2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Merge").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Sheets("UW1").Select
Range("A2:Y2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Merge").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Sheets("UW2").Select
Range("A2:Y2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Merge").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Range("A1").Select
Call cleanData
Application.ScreenUpdating = True
MsgBox "Collation of data complete", vbInformation
End Sub
The code throws error at this juncture
Code:
ActiveCell.Offset(1, 0).Select
Sheets("UW2").Select
Is there any issue if we filter the data in the sheet and then try to run this code. Is there any turn-around to deal with this issue.
Regards,
JD