Hi everyone. I am not good with VBA at all and really hope that you can help! I need the macro to find and compare different peaces of data and if there are differences between them - paste out the row on a separate sheet. The problem is that I need a variable from where the data is taken in the first place so that the excel would go through all the data I need to search for.
So far I have this:
It works fine for the first time but after Next X it returns an error that Object variable or With Block is not set. Can anyone spot the mistake?
Thanks in advance!
So far I have this:
Code:
Sub Macro1()
Dim X As Integer
For X = 2 To 10
If Cells.Find(What:=Sheets("current month").Cells(X, 1), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate = True Then
ActiveCell.EntireRow.Select
Selection.Copy
Sheets("Sheet1").Select
Rows(X).Select
ActiveSheet.Paste
Else
MsgBox ("AAA")
End If
Next X
End Sub
It works fine for the first time but after Next X it returns an error that Object variable or With Block is not set. Can anyone spot the mistake?
Thanks in advance!