Macro skipping

D

DN

Hi,

I have a simple macro with the commented code shown below. For some reason
when I run the macro it will skip over the else condition. If I run the
macro a few times on data that it skipped over it will work. Any help is
greatly appreciated. Thanks!

Dave.

example of the input:
0001
0001
0002
0002
0003
0004
0004
0004

Sub InsertRow()

Dim d As Integer

' This loop runs until there is nothing in the below row

Do

' If the cell below has the same value as the current cell then go down to
the next cell

If ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then

ActiveCell.Offset(1, 0).Select

Else

'Else insert a new row

ActiveCell.Offset(1, 0).Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(1, 0).Select

End If

Loop Until IsEmpty(ActiveCell.Value)


End Sub
 
G

Gary Keramidas

worked for me, all i can think of is that your activecell is not what you think
it is
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top