I have this VBA to copy a row from a master sheet. I want it to stop pasting data after row L. Any thoughts as to what is wrong?
Dim ws As Worksheet, wo As Worksheet
Dim r As Long, lr As Long, lc As Long, n As Long, sr As Long, nr As Long
sr = 4
Set ws = Sheets("Raw Data - Funnel")
Set wo = Sheets("Corporate Funnel")
lr = ws.Cells(Rows.Count, 2).End(xlUp).Row
lc = ws.Cells(3, Columns.Count).End(xlToLeft).Column
For r = 4 To lr Step 1
n = Application.CountIf(ws.Range(ws.Cells(r, 4), ws.Cells(r, lc)), "Corporate")
If n > 0 Then
nr = wo.Range("B" & Rows.Count).End(xlUp).Offset(1).Row
If nr < sr Then nr = sr
ws.Rows(r).Copy wo.Rows(nr)
End If
Bookmarks