Option Explicit
Hello, a few weeks ago asked for code that would to delete rows for any cells that are <>5. The code worked famously with one exception...The Header Row in Row 1 (Column Titles) are wiped out when I use the code. I've been trying for a few hours today to fix it to no avail. As always any help would be appreciated.
Region RWA Type RWA Number First Name Last Name
1 N 2153015 John Jerod
1 1549242 Jerry Jipp
1 3990388 Joeseph Jestrand
5 5481055 Jasper Jakula
5 2584318 James Jeree
5 9097163 Jules Haney
5 N 1436244 Joshua Hickly
5 N 1345162 Jester Halter
'Sub Overobligated()
Dim i As Integer
Dim LastRow As Long
'Deletes all Rows that = "5"
Dim x As Integer
For x = Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Rows.Count To 1 Step -1
If Cells(x, 1).Value <> 5 Then Cells(x, 1).EntireRow.Delete Shift:=xlUp
Next x
Hello, a few weeks ago asked for code that would to delete rows for any cells that are <>5. The code worked famously with one exception...The Header Row in Row 1 (Column Titles) are wiped out when I use the code. I've been trying for a few hours today to fix it to no avail. As always any help would be appreciated.
Region RWA Type RWA Number First Name Last Name
1 N 2153015 John Jerod
1 1549242 Jerry Jipp
1 3990388 Joeseph Jestrand
5 5481055 Jasper Jakula
5 2584318 James Jeree
5 9097163 Jules Haney
5 N 1436244 Joshua Hickly
5 N 1345162 Jester Halter
'Sub Overobligated()
Dim i As Integer
Dim LastRow As Long
'Deletes all Rows that = "5"
Dim x As Integer
For x = Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Rows.Count To 1 Step -1
If Cells(x, 1).Value <> 5 Then Cells(x, 1).EntireRow.Delete Shift:=xlUp
Next x