View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Auto insert of blank row depending on data

Sub push_row()
Dim v1 As Variant, v2 As Variant
For i = 2 To Rows.Count
If IsEmpty(Cells(i, 1)) Then Exit Sub
v1 = Cells(i, 1).Value
v2 = Cells(i - 1, 1).Value
If v1 < v2 Then
Cells(i, 1).EntireRow.Insert
Cells(i, 1).EntireRow.Insert
i = i + 2
End If
Next
End Sub
--
Gary''s Student - gsnu2007b


" wrote:

I'm trying to get myself a macro so I can analyse my data but after
running it a couple of times (and changing info) the results don't
come out as planned. Basically what I'm trying to do is get it to
insert two blank rows when a change in data happens. For example:

1
1
1
1
2
2
2

It should insert two blank rows between the 1 and 2. The problem is
that the data is not in sequence and sometimes is not a number. I need
it to recognise a change regardless of what the value is. Any help/
code would be appreciated