J
Janis
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
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