![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 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. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
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.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 26
|
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 " Thanks |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
You can do a find and replace to make them all the same text.
__________________
Kind regards, Al Chara |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|