Delete rows

DavidC

New Member
Joined
Mar 17, 2002
Messages
26
I am trying to delete rows based on text contained in column C, but it only deletes the first instance it finds, cause after that it starts looking in column A. This is my code, which I wrote based on a previous post:

Range("C1").Select
For i = 1 To 2048
If ActiveCell.Value Like "TEXT" Then
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(RowOffset:=1).Select
End If
Next i

How do I get it to keep looking in column C, instead of switching to A?

Also, since my data is from all regions of the country and each region does things a little different, how do I have it delete rows based on several different text criteria. Would I have to run the whole thing a separate time for each text criteria, or can I have it do it once?

Thanks.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try the following code for the answer to your first question:

Range("C1").Select
For i = 1 To 2048
If ActiveCell.Value Like "TEXT" Then
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(0, 2).Select
Else
ActiveCell.Offset(RowOffset:=1).Select
End If
Next i

Give an example of your second question.
 
Upvote 0
Awesome, that worked.

As for my second question, I am deleting rows that say "NOT EQUIPPED". But some of the data says "NOT EQUIPED", or "NE", or "<NOT EQUIPPED>", etc. I have actually identified 7 or 8 different variations that I need to use a criteria to delete rows.

Thanks
 
Upvote 0

Forum statistics

Threads
1,213,492
Messages
6,113,967
Members
448,537
Latest member
Et_Cetera

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