vzachin
09-14-2007, 11:59 AM
Hi,
I have data beginning in Cell B5 to B5000. I need to insert a blank row whenever each subsequent cell does not equal the previous cell.
i have something like this, but it's not working correctly if B5 & B6 is the same
how can i rewrite this code so that it would work properly? and can i make this code cleaner?
Sub SortMoreOc()
Sheets("test").Select
For i = 5 To ActiveSheet.Rows.Count
TermZ0 = Range("B" & i)
TermZ1 = Range("B" & i + 1)
If TermZ0 <> TermZ1 Then
With Range("B" & i)
.EntireRow.Insert
End With
If TermZ1 = "" Then
Exit Sub
End If
i = i + 1
End If
Next
End Sub
thanks
zach
I have data beginning in Cell B5 to B5000. I need to insert a blank row whenever each subsequent cell does not equal the previous cell.
i have something like this, but it's not working correctly if B5 & B6 is the same
how can i rewrite this code so that it would work properly? and can i make this code cleaner?
Sub SortMoreOc()
Sheets("test").Select
For i = 5 To ActiveSheet.Rows.Count
TermZ0 = Range("B" & i)
TermZ1 = Range("B" & i + 1)
If TermZ0 <> TermZ1 Then
With Range("B" & i)
.EntireRow.Insert
End With
If TermZ1 = "" Then
Exit Sub
End If
i = i + 1
End If
Next
End Sub
thanks
zach