LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default for loop doesn't advance

Program is not advancing to the next Service Group. It keeps adding sets of
20 rows. It is starting on the 7th row and adding row after row in the same
place. It should start on the 8th row and add 20 rows and then advance.

Exactly what I want it to do is compare the value in cells in column H
(starting with SG01 then before it gets to the next one , store the count of
rows, for the 1st service group, which in most cases is 16. Then it has to
divide that count in half and add 20 rows to the first half and 20 rows to
the second half on to the end of the sheet. There are many sheets to do this
on and the number of service groups vary as do the row count.

Then it has to advance to the next service group which is where it is
failing. It isn't advancing.

tia,

Public Sub n2m_3()
Const ServiceGroupColumn As String = "$H"
Const FirstDataRow As Integer = 12

Dim UsedRange1 As Range
Dim Rows() As Variant
Dim i As Long
Dim UsedCol1 As Long
Dim C As Range
Dim Second_QAM_IP As Integer


Set UsedRange1 = Intersect(Range(ServiceGroupColumn & FirstDataRow & ":" &
ServiceGroupColumn & ActiveSheet.UsedRange.Rows.Count), ActiveSheet.UsedRange)
UsedRange1.Select

i = 0

For Each C In UsedRange1
If ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then
ActiveCell.Offset(1, 0).Activate

i = i + 1
Else
Second_QAM_IP = Round(i / 2)

ActiveCell.Offset(-Second_QAM_IP, 0).Resize(20).EntireRow.Insert
ActiveCell.Offset(Second_QAM_IP, 0).Resize(20).EntireRow.Insert
i = 1
End If

Next C


End Sub

 
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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
How to Advance a For Next Loop prior to the Next Statement ExcelMonkey Excel Programming 1 August 9th 05 06:13 PM
I need a little help...thanks in advance Jambruins Excel Discussion (Misc queries) 1 August 3rd 05 06:00 PM
Here's one for you...(thanks for the help in advance) Jambruins Excel Discussion (Misc queries) 2 July 15th 05 07:41 PM
Boolean to advance loop ExcelMonkey[_190_] Excel Programming 1 March 14th 05 06:41 PM


All times are GMT +1. The time now is 11:48 AM.

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"