whats wrong

Private Sub Workbook_Open()
Dim i, Lastrow
Lastrow = Sheets("Master").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Card Takings").Range("A2:N10000").ClearContents
For i = 2 To Lastrow
If Sheets("Master").Cells(i, "D").Value = "Card Payment" Then
Sheets("Master").Cells(i, "D").EntireRow.Copy Destination:=Sheets("Card Takings").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i

End Sub

can any one see whats wrong with this ... i copied and pasted from another that is woking fine and just changed the sheet names

Nick's picture

are the sheet names correct ?

are the sheet names correct ?

have checked the sheet names

have checked the sheet names and the spellings ...
this is one i did for Cash Payments and ia working fine ... all i did was copy and past and then amend the sheet names

Private Sub Workbook_Open()
Dim i, Lastrow
Lastrow = Sheets("Master").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Cash Takings").Range("A2:N10000").ClearContents
For i = 2 To Lastrow
If Sheets("Master").Cells(i, "D").Value = "Cash Payments" Then
Sheets("Master").Cells(i, "D").EntireRow.Copy Destination:=Sheets("Cash Takings").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i

End Sub