Hello, I'm trying to edit this code that you had previously sent to me...which worked perfectly. However my supervisor asked to delete rows that are <1500 and > 1599.
Dim y As Long
For y = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(y, 12).Value < 1500 > 1599 Then Cells(y, 1).EntireRow.Delete Shift:=xlUp
Next y
I have tried several edits to no avail. I even tried the following:
Dim y As Long
For y = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(y, 12).Value < 1500 Then Cells(y, 1).EntireRow.Delete Shift:=xlUp
Next y
along with
Dim x As Long
For x = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(x, 12).Value > 1599 Then Cells(x, 1).EntireRow.Delete Shift:=xlUp
Next x
This last double entry worked with the exception that Row 2 was evaluated for some reason. Row 1 has all Header Titles
Using the double code (dim y as long) in the first for < 1500 and (dim x as long) for <1599.
Before After
L L
1650 1650 - wrong, > 1500 row should deleted
1535 1535 - correct
1755 1755 - correct
1352 1352 - correct
1599 1599 - correct
Finally, can you explain the code step by step. I'd like to see why the first row is deleted. Thanks in advance
Dim y As Long
For y = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(y, 12).Value < 1500 > 1599 Then Cells(y, 1).EntireRow.Delete Shift:=xlUp
Next y
I have tried several edits to no avail. I even tried the following:
Dim y As Long
For y = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(y, 12).Value < 1500 Then Cells(y, 1).EntireRow.Delete Shift:=xlUp
Next y
along with
Dim x As Long
For x = Range("L1:L" & Range("L" & Rows.Count).End(xlUp).Row).Rows.Count To 2 Step -1
If Cells(x, 12).Value > 1599 Then Cells(x, 1).EntireRow.Delete Shift:=xlUp
Next x
This last double entry worked with the exception that Row 2 was evaluated for some reason. Row 1 has all Header Titles
Using the double code (dim y as long) in the first for < 1500 and (dim x as long) for <1599.
Before After
L L
1650 1650 - wrong, > 1500 row should deleted
1535 1535 - correct
1755 1755 - correct
1352 1352 - correct
1599 1599 - correct
Finally, can you explain the code step by step. I'd like to see why the first row is deleted. Thanks in advance