Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Delete rows

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 "", etc. I have actually identified 7 or 8 different variations that I need to use a criteria to delete rows.

    Thanks

  4. #4
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can do a find and replace to make them all the same text.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •