Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a Row Range at regular intervals

Hi, I hope some of you can help me.

I have a spreadsheet that has a row of data evenly spaced down my
spreadhsheet (say, for the sake of it, each row has 10 rows in between
it and the previous one.

I need to insert a named row range, copied from another worksheet, 2
lines before each row (so that there is a blank line in between the
inserted range and the next row). (I'm thinking that this is a better
way than counting 8 rows down, inserting, then counting down the
height of the range + 2 to get to the next row).

It doesn't matter if it goes too far - I can always delete the
unneeded inserted ranges.

I presume I'd need to copy the range and use Selection.Insert
Shift:=xlDown. I'd originally thought about adding blank rows and
copying/pasting into it, but that seemed to be overkill.

How do I keep control of the activecell in order to make sure the
inserts go in the correct place?
Is there a quick way to copy the named range rather than jumping
between worksheets?

Any help you can give would be much appreciated :)
math

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Inserting a Row Range at regular intervals

Here is a general approach:

Sub Test1()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 1 Step -10
Range("MyRange").EntireRow.Copy
Rows(i).EntireRow.Insert
Next


End Sub

you can work out the adjustments. Obviously test on copies of your data.

--
Regards,
Tom Ogilvy


" wrote:

Hi, I hope some of you can help me.

I have a spreadsheet that has a row of data evenly spaced down my
spreadhsheet (say, for the sake of it, each row has 10 rows in between
it and the previous one.

I need to insert a named row range, copied from another worksheet, 2
lines before each row (so that there is a blank line in between the
inserted range and the next row). (I'm thinking that this is a better
way than counting 8 rows down, inserting, then counting down the
height of the range + 2 to get to the next row).

It doesn't matter if it goes too far - I can always delete the
unneeded inserted ranges.

I presume I'd need to copy the range and use Selection.Insert
Shift:=xlDown. I'd originally thought about adding blank rows and
copying/pasting into it, but that seemed to be overkill.

How do I keep control of the activecell in order to make sure the
inserts go in the correct place?
Is there a quick way to copy the named range rather than jumping
between worksheets?

Any help you can give would be much appreciated :)
math


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
Inserting a Value into a Range Andy Excel Programming 3 March 3rd 06 07:07 PM
How to trigger a macro at regular intervals? ÉH Excel Programming 3 January 6th 06 09:10 PM
Count cells in range that restarts at intervals Melissa Excel Discussion (Misc queries) 2 August 19th 05 02:20 PM
Count cells in range that restarts at intervals Rowan Excel Discussion (Misc queries) 2 August 19th 05 05:35 AM
copy/inserting rows at specific intervals mark Excel Programming 1 October 17th 03 10:58 PM


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