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 adding some rows in the middle of adding some other rows

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
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
Adding rows based on no of rows specified from a given position nanette Excel Worksheet Functions 1 July 9th 08 02:29 PM
Adding Rows Paul_of_Abingdon Excel Discussion (Misc queries) 5 February 22nd 08 10:48 PM
Adding five new rows every 40 rows in a spreadsheet? Olzki Excel Discussion (Misc queries) 8 May 18th 07 02:14 AM
Adding Rows offsets to working rows across two worksheets tom Setting up and Configuration of Excel 3 July 30th 06 07:54 PM
Adding new rows Paul Sheppard Excel Discussion (Misc queries) 2 July 28th 05 06:05 AM


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

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

About Us

"It's about Microsoft Excel"