lisa duncan
New Member
- Joined
- Jan 5, 2011
- Messages
- 11
I have a macro that should compare two worksheets; then any differences should be put on a third worksheet. The worksheets are very large and the range is from colums A to H and the rows are from 1 to 62512 on the second sheet and 1 to 60118 on the first sheet
Below is the macro when I run it I get an error of 400
Any help would be greatly appreciated!
Sub compareDiff()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim WS1 As Worksheet, WS2 As Worksheet, WS3 As Worksheet, LR&, i&, j&
Set WS1 = Worksheets("Sheet1") 'Change name as required
Set WS2 = Worksheets("Sheet2")
Set WS3 = Worksheets("Sheet3")
LR = WS1.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
For j = 1 To 8
If WS2.Cells(i, j).Text <> WS1.Cells(i, j).Text Then
WS3.Cells(i, j).Text = WS2.Cells(i, j).Text & " <> " & WS1.Cells(i, j).Text
End If
Next j
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Below is the macro when I run it I get an error of 400
Any help would be greatly appreciated!
Sub compareDiff()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim WS1 As Worksheet, WS2 As Worksheet, WS3 As Worksheet, LR&, i&, j&
Set WS1 = Worksheets("Sheet1") 'Change name as required
Set WS2 = Worksheets("Sheet2")
Set WS3 = Worksheets("Sheet3")
LR = WS1.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
For j = 1 To 8
If WS2.Cells(i, j).Text <> WS1.Cells(i, j).Text Then
WS3.Cells(i, j).Text = WS2.Cells(i, j).Text & " <> " & WS1.Cells(i, j).Text
End If
Next j
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub