Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Insert a row based on criteria (excel xp)

    I need to search through col B and Col E and insert a blank row if COL B has the text "(A)" AND COL E has the text "B"

    For iRow = 1 To lLastRow
    rngCell.Value="(A)" and rngCell.offset(0,3).value="B" then
    Rows(iRow).EntireRow.Insert
    End If
    Next iRow

    I don't think i have it exactly right. Thank you for the help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Insert a row based on criteria (excel xp)

    - You don't set rngCell anywhere in this code.
    - There is no If corresponding to the Then.
    - When inserting or deleting rows, you must loop backwards. If you loop forwards, inserting/deleting rows will interfere with where you are going.

    For iRow = ILastRow To 1 Step -1
    If Cells(iRow, 2)="(A)" And Cells(iRow, 5)="B" then
    Rows(iRow).EntireRow.Insert
    End If
    Next iRow

Posting Permissions

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