J
Janis
This works except it doesn't add the 32 rows to the first service group at
the very top of the sheet presumably because after the firstdatarow is text
in the header row. So when it tries the test, with the header row, SG01 <>
some text it fails or because it is supposed to stop at the firstdatarow. I
tried changing the firstdatarow to 11 instead of 12 hoping it wouldn't match
so it would go ahead and add the rows to the first service group. do I have
to write a loop just to get it to finish? I hope there is an easy solution.
It does the test on the service group column "H".
tia,
Public Sub n2m4()
Const ServiceGroupColumn As String = "$H"
Const FirstDataRow As Integer = 12
Dim iRow As Long
Dim rowsToAdd As Integer
Dim LastRow As Long
Dim i As Integer
Dim rng As Range
Dim SvcGrpNum As Long
SvcGrpNum = InputBox("Please input the the total number of Service Group
connections from the DNP", "Service Group Number", 48)
With ActiveWorkbook.Worksheets("VOD")
LastRow = .Cells(.Rows.count, ServiceGroupColumn).End(xlUp).Row
i = 1
For iRow = LastRow To FirstDataRow Step -1
i = i + 1
If .Cells(iRow, ServiceGroupColumn).Value = .Cells(iRow - 1,
ServiceGroupColumn).Value Then
Else
rowsToAdd = SvcGrpNum - i
rng.Offset(SvcGrpNum / 2, 0).Resize(rowsToAdd +
1).EntireRow.Insert
i = 1
End If
Next iRow
End With
End Sub
the very top of the sheet presumably because after the firstdatarow is text
in the header row. So when it tries the test, with the header row, SG01 <>
some text it fails or because it is supposed to stop at the firstdatarow. I
tried changing the firstdatarow to 11 instead of 12 hoping it wouldn't match
so it would go ahead and add the rows to the first service group. do I have
to write a loop just to get it to finish? I hope there is an easy solution.
It does the test on the service group column "H".
tia,
Public Sub n2m4()
Const ServiceGroupColumn As String = "$H"
Const FirstDataRow As Integer = 12
Dim iRow As Long
Dim rowsToAdd As Integer
Dim LastRow As Long
Dim i As Integer
Dim rng As Range
Dim SvcGrpNum As Long
SvcGrpNum = InputBox("Please input the the total number of Service Group
connections from the DNP", "Service Group Number", 48)
With ActiveWorkbook.Worksheets("VOD")
LastRow = .Cells(.Rows.count, ServiceGroupColumn).End(xlUp).Row
i = 1
For iRow = LastRow To FirstDataRow Step -1
i = i + 1
If .Cells(iRow, ServiceGroupColumn).Value = .Cells(iRow - 1,
ServiceGroupColumn).Value Then
Else
rowsToAdd = SvcGrpNum - i
rng.Offset(SvcGrpNum / 2, 0).Resize(rowsToAdd +
1).EntireRow.Insert
i = 1
End If
Next iRow
End With
End Sub