你可以用這個
Option Explicit
Sub CompareBooking()
Dim rng1 As Range, rng2 As Range
Dim iRow As Long
Dim diffs As String
With Workbooks("Booking1Wb").Worksheets("booking1") '<--| change "Booking1Wb" and "booking1" to, respectively, your actual workbook and its worksheet names where to find booking numbers from C3 downwards
Set rng1 = .Range("C3", .Cells(.Rows.count, "C").End(xlUp)) '<--| change "Booking2Wb" and "booking2" to, respectively, your actual workbook and its worksheet names where to find booking numbers from L3 downwards
End With
With Workbooks("Booking2Wb").Worksheets("booking2")
Set rng2 = .Range("L3", .Cells(.Rows.count, "L").End(xlUp))
End With
For iRow = 1 To WorksheetFunction.Max(rng1.Rows.count, rng2.Rows.count)
If rng1(iRow) <> rng2(iRow) Then diffs = diffs & iRow & vbLf
Next
If diffs <> "" Then
MsgBox "Different booking numbers in rows:" & vbCrLf & vbCrLf & diffs
Else
MsgBox "All bookings match"
End If
End Sub
如果所有項目都匹配,但順序不同? –