Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This macro does half of what I want it to do. I need it also to add the same
number of rows as on the insert line only this time in the middle of the service group. Since it already added half of the rows at the end of the first service group how do I get it to go to the middle of the service group add the same number of rows and not get out of step for the next service group? tia, Public Sub n2m4() 'adds new rows for connections to VOD sheet ' default total rows to add 40 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 'Dim SvcGrp As Long SvcGrpNum = InputBox("Please input the the total number of Service Group connections from the DNP", "Service Group Number", 40) 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 ' If ((SvcGrpNum - i) / 2) And 1 Then ' SvcGrp = .Cells(iRow, ServiceGroupColumn).Value ' MsgBox ("Service Group" & " " & SvcGrp & " " & "has an odd number of rows. Please add a row and start over.") ' Else rowsToAdd = (SvcGrpNum - i) / 2 .Cells(iRow, ServiceGroupColumn).Resize(rowsToAdd).EntireRow.In sert i = 1 End If ' End If Next iRow End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding rows based on no of rows specified from a given position | Excel Worksheet Functions | |||
Adding Rows | Excel Discussion (Misc queries) | |||
Adding five new rows every 40 rows in a spreadsheet? | Excel Discussion (Misc queries) | |||
Adding Rows offsets to working rows across two worksheets | Setting up and Configuration of Excel | |||
Adding new rows | Excel Discussion (Misc queries) |