PDA

View Full Version : [SOLVED] Compare 2 columns, add blank rows



hobgoblin
08-23-2005, 12:04 PM
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 : pray2: Thanks.

Jacob Hilderbrand
08-23-2005, 12:58 PM
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

hobgoblin
08-23-2005, 01:37 PM
Looks very promissing :) TY

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

Jacob Hilderbrand
08-23-2005, 03:52 PM
You're Welcome :beerchug:

Take Care