Consulting

Results 1 to 5 of 5

Thread: Compare 2 columns, add blank rows

  1. #1

    Compare 2 columns, add blank rows

    Hi all, What i have is two columns. In the 1st one there are a lot of doubles, the second 1 doesnt have any. What im trying to do is to compare these two columns and to adjust the second one so it has the same length as the 1st. So I am adding blank row if necessary.

    Ex Column1 Column 2 Output
    1 1 1
    1 2
    2 3 2
    3 4 3
    4 5 4
    4
    5 5

    Puhleeeeaaaaassssse Thanks.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this.


    Option Explicit
     
    Sub InsertRows()
    Dim i               As Long
    Dim LastRow         As Long
    LastRow = Range("A65536").End(xlUp).Row
    For i = 1 To LastRow
            If Range("B" & i).Text <> Range("A" & i).Text Then
                Range("B" & i).Insert Shift:=xlDown
                i = i + 1
            End If
        Next i
    End Sub

  3. #3
    Looks very promissing TY

  4. #4
    That's it !!!!!! Thank you DRJ. Just when you think you know excel, you find out that you are a total noob ( That's my case) Anyhow, again, thanks a whole lot, you just saved me about 4-5 hours of coding/ testing. Bye

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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