Consulting

Results 1 to 4 of 4

Thread: insert empty row where the content between two lines are different

  1. #1

    insert empty row where the content between two lines are different

    Hi, now I have a list on sheet1 with not totally empty row and I have to do the following: I have to insert one entire empty row when the team name changes...and it should look like the one on tab "teams CW". I tried to write a piece of code(which is not in the attachment), but it only incerts a lot of rows under the first row.

    so is there a method to do so, without the code to find a certain name of a team and insert one row above...because I have like 30 teams later, and it will be a lot of work.

    thanks!
    Attached Files Attached Files

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    you have to do it starting from the last row going up instead
    [VBA]Sub insert_rows()

    Dim lr As Long, i As Long
    ActiveWorkbook.Sheets("teams CW").Activate
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = lr To 3 Step -1
    If Cells(i, 3).Text <> Cells(i - 1, 3).Text Then
    Cells(i, 1).EntireRow.Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End If
    Next i
    End Sub[/VBA]
    ------------------------------------------------
    Happy Coding my friends

  3. #3
    works perfectly, thank you so much

  4. #4
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    no problem
    ------------------------------------------------
    Happy Coding my friends

Posting Permissions

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