Code:
Sub ToSummary()
Dim wsM As Worksheet
Set wsM = Sheets("Billings")
Dim lrSort As Long
Dim wsS As Worksheet
Set wsS = Sheets("Summary")
Dim Z As Integer
Z = 10
lrSort = wsM.Range("C65536").End(xlUp).Row
' On Error Resume Next
For X = 2 To lrSort
Y = Empty
Y = Applicaion.WorksheetFunction.Match(wsM.Cells(X, 1), wsS.Cells(2, 1), 0)
If Application.IsNumber(Y) Then
wsM.Cells(X, 1).Resize(1, 7).Copy Destination:=wsS.Cells(Z, 1)
Z = Z + 1
End If
Next X
End Sub
I try to copy worksheet wsM to worksheet wsS when wsM.Cells(x,1) match with wsS.Cells(2,1).
Debugger told me 424 error message -- Object required in line "Y=Application.WorksheetFunction.Match(wsM.Cells(X,1), wsS.Cells(2,1), 0)".
My wsM sheet is:
Item Location Qty
A Warehouse1 10
A Warehouse2 20
B Warehouse1 20
B Warehouse2 30
My wsS sheet is:
Item
A
[TABLE="width: 240"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD]
I already checked the value of wsM.Cells(X,1) and wsS.Cells(2,1) = A when I step into my code.[/TD]
[TD][/TD]
[TD="align: right"]
[/TD]
[/TR]
</tbody>[/TABLE]
Last edited by a moderator: