How to NOT delete header row

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
730
Office Version
  1. 365
Platform
  1. Windows
The code below is what I use to filter records for a particular person. If the cell doesn't match what's in K3 it's deleted. But that also deletes the top row with my headers. How can I modify this to leave row 1?


'DELETE all records except those for the Username specified in K3
Sheets("Pending").Select
Last = Cells(Rows.Count, "L").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "L").Value) <> Worksheets("Sheet3").Range("K3") Then
Cells(i, "A").EntireRow.Delete
End If
Next i
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Change this:
Rich (BB code):
For i = Last To 1 Step -1
to this:
Rich (BB code):
For i = Last To 2 Step -1
which tells it to start at the bottom at stop at row 2 (instead of row 1).
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top