PC Review


Reply
Thread Tools Rate Thread

algorithm to add 20 rows at half way point & at beginning

 
 
=?Utf-8?B?SmFuaXM=?=
Guest
Posts: n/a
 
      3rd Oct 2007
I must need a loop or something at the asterisks. Now as it is, my code adds
half of the needed 40 rows (20)each at the beginning of each service group
all the way through (or you might say at the end of the preceeding group).
That is okay, but I also need it to add one set of (20) rows at the very
beginning(which at this case is the end since I'm going in reverse. How can
I add the very first 20 rows?
The 2nd problem is I need to add the other 20 rows at the half way point in
each service group. As you can see with the comments I can't quite get it to
get it right.
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", 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


rowsToAdd = (SvcGrpNum - i) / 2

.Cells(iRow,
ServiceGroupColumn).Resize(rowsToAdd).EntireRow.Insert **I*
'.Cells(iRow, ServiceGroupColumn).Offset(i /
2).Resize(rowsToAdd).EntireRow.Insert
'.Cells(iRow, ServiceGroupColumn).Offset(-(SvcGrpNum / 2) +
rowsToAdd).Resize(rowsToAdd).EntireRow.Insert


i = 1
End If

Next iRow

End With

End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFuaXM=?=
Guest
Posts: n/a
 
      3rd Oct 2007
I will repost question to clarify.

"Janis" wrote:

> I must need a loop or something at the asterisks. Now as it is, my code adds
> half of the needed 40 rows (20)each at the beginning of each service group
> all the way through (or you might say at the end of the preceeding group).
> That is okay, but I also need it to add one set of (20) rows at the very
> beginning(which at this case is the end since I'm going in reverse. How can
> I add the very first 20 rows?
> The 2nd problem is I need to add the other 20 rows at the half way point in
> each service group. As you can see with the comments I can't quite get it to
> get it right.
> 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", 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
>
>
> rowsToAdd = (SvcGrpNum - i) / 2
>
> .Cells(iRow,
> ServiceGroupColumn).Resize(rowsToAdd).EntireRow.Insert **I*
> '.Cells(iRow, ServiceGroupColumn).Offset(i /
> 2).Resize(rowsToAdd).EntireRow.Insert
> '.Cells(iRow, ServiceGroupColumn).Offset(-(SvcGrpNum / 2) +
> rowsToAdd).Resize(rowsToAdd).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
what is best algorithm to check duplicated rows Ryan Liu Microsoft C# .NET 7 5th Mar 2012 05:55 PM
What algorithm is used for rounding when doing a narrowing conversion between floating point numeric types? Nathan Sokalski Microsoft Dot NET Framework 0 19th Oct 2008 06:02 PM
print half of rows on left and other half on right =?Utf-8?B?U3RldmUgQi4=?= Microsoft Excel Misc 2 16th Nov 2007 11:20 AM
Beginning Point Russ Microsoft Access Forms 5 17th Jul 2006 09:30 PM
restore point beginning or end ? Greg Windows XP Performance 1 1st Apr 2004 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 AM.