Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DN DN is offline
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference row on another sheet skipping zeros but not skipping li. Brennan Downes Excel Discussion (Misc queries) 2 April 2nd 23 01:28 PM
Macro Skipping a column? Darin Kramer Excel Programming 3 August 25th 06 09:43 AM
Macro - Skipping a line PaulPoll Excel Worksheet Functions 4 December 21st 04 12:43 AM
Macro skipping blank cell bossbubba Excel Programming 1 February 5th 04 07:50 PM
Macro skipping even rows Bob Phillips[_5_] Excel Programming 5 July 26th 03 12:29 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"