Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default adds rows to all service groups except the first one

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

Reply
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
Discussion Groups Websites Service Temporarily Unavailable aussiegirlone Excel Discussion (Misc queries) 15 March 27th 09 12:38 PM
need to stuff the array with the nth number of service groups Janis Excel Programming 3 September 24th 07 11:36 PM
need to add 24 rows to each service group Janis Excel Programming 5 September 24th 07 09:40 PM
shared file adds or deletes rows woodman Excel Discussion (Misc queries) 0 May 31st 07 04:46 PM
Help: Macro Adds Rows, Need to Update Totals with New rows Matt[_39_] Excel Programming 2 August 7th 06 05:06 PM


All times are GMT +1. The time now is 09:42 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"