Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro skipping
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
reference row on another sheet skipping zeros but not skipping li. | Excel Discussion (Misc queries) | |||
Macro Skipping a column? | Excel Programming | |||
Macro - Skipping a line | Excel Worksheet Functions | |||
Macro skipping blank cell | Excel Programming | |||
Macro skipping even rows | Excel Programming |