Newbie here on Excel VBA. I would just like to ask how to fix the error I'm getting? I'm trying to copy an entire row base on a criteria, and paste it on another sheet (same workbook). Here's my code:
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim endRow As Range
Set ws = Sheets("FIELD OFFICE DATABASE")
Set ws1 = Sheets("Transferred Items")
set endRow = Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
ws.Activate
ws.Unprotect "321321"
Range("B2").Select
Do Until endRow
If ActiveCell.Value = Me.cmbemn.Text Then
ActiveCell.Rows("B:S").Select
Selection.copy
ws1.Activate
ws1.Unprotect "321321"
endRow.Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
What happens is its either my Excel crashes, or an error pops up saying "Object required". But mostly it crashes.
Please help! Thanks!