PC Review


Reply
Thread Tools Rate Thread

adds rows to all service groups except the first one

 
 
=?Utf-8?B?SmFuaXM=?=
Guest
Posts: n/a
 
      4th Oct 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Add/Remove Rows Code" adds rows on grouped sheets, but won't remove rows. Conan Kelly Microsoft Excel Programming 1 16th Nov 2007 10:41 PM
Help: Macro Adds Rows, Need to Update Totals with New rows Matt Microsoft Excel Programming 2 7th Aug 2006 05:06 PM
Adding a row to dataset adds two rows to datagrid dbuchanan Microsoft Dot NET Framework Forms 2 3rd May 2005 08:37 PM
XP Pro adds extra rows to printer. Ron Huffman Windows XP Hardware 8 10th Mar 2005 05:56 AM
Force adds to Administrators local groups via OU?? Richard Roche Microsoft Windows 2000 Group Policy 2 17th Sep 2003 03:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:27 AM.