#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default insert rows

i have several columns of information, one of them being "claim number" and
another being "report number" (report numbers are 1 through 5...there is
always at least a 1, or maybe 1 and 2...etc) I need to have 5 instances of
each claim number. What code could i use so that it would look at the
report number and if its a "1" then look at the next line and if that is
also a "1" insert 4 rows below it, if the report number is a "1" and next
line is a "2" then insert 3 rows below it...etc. Basically I want the macro
to scan the column and each time there is a "1" to look at the previous line
to get report value "x", get the report number and insert 5-x rows below it.

if anyone needs clarification let me know.

Thanks,
Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default insert rows

Sub AddLines()
Dim rng As Range
Dim i As Long
Dim num As Long
Set rng = Cells(Rows.Count, 1).End(xlUp)

For i = rng.Row To 2 Step -1
If Cells(i + 1, 1).Value < Cells(i, 1).Value And _
Cells(i + 1, 1) < "" Then
num = 5 - Cells(i, 2).Value
If num 0 Then
Cells(i + 1, 1).Resize(num).EntireRow.Insert
End If
End If
Next

End Sub


Might be what you want.

Test on a copy of your data.

--
Regards,
Tom Ogilvy



"dave!!" wrote in message
...
i have several columns of information, one of them being "claim number"

and
another being "report number" (report numbers are 1 through 5...there is
always at least a 1, or maybe 1 and 2...etc) I need to have 5 instances

of
each claim number. What code could i use so that it would look at the
report number and if its a "1" then look at the next line and if that is
also a "1" insert 4 rows below it, if the report number is a "1" and next
line is a "2" then insert 3 rows below it...etc. Basically I want the

macro
to scan the column and each time there is a "1" to look at the previous

line
to get report value "x", get the report number and insert 5-x rows below

it.

if anyone needs clarification let me know.

Thanks,
Dave




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
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
How do i insert blank rows between data that is thousands of rows paul.eatwell Excel Discussion (Misc queries) 5 April 14th 08 10:49 PM
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
How do I insert blank rows between rows in completed worksheet? bblue1978 Excel Discussion (Misc queries) 1 October 26th 06 07:02 PM
How do i insert of spacer rows between rows in large spreadsheets laurel Excel Discussion (Misc queries) 0 April 24th 06 01:38 PM


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

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"