Thread: Macro skipping
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Macro skipping

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

--


Gary


"DN" wrote in message
...
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