Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Inserting Rows

My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?


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

Sub Tester10()
Set rng = Cells(5, 1)
For i = 9 To 1000 Step 4
If IsEmpty(Cells(i, 1)) Then Exit For
Set rng = Union(rng, Cells(i, 1))
Next
If Not rng Is Nothing Then
rng.EntireRow.Insert
End If
End Sub

Tested in Excel 2000. Not sure it would work in xl97, but haven't tested
there. Should work in xl2000 and later I would think.

--
Regards,
Tom Ogilvy


"Phil" wrote in message
...
My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Inserting Rows

Tom, tested in '97 works fine

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **

"Tom Ogilvy" wrote in message
...
Sub Tester10()
Set rng = Cells(5, 1)
For i = 9 To 1000 Step 4
If IsEmpty(Cells(i, 1)) Then Exit For
Set rng = Union(rng, Cells(i, 1))
Next
If Not rng Is Nothing Then
rng.EntireRow.Insert
End If
End Sub

Tested in Excel 2000. Not sure it would work in xl97, but haven't tested
there. Should work in xl2000 and later I would think.

--
Regards,
Tom Ogilvy


"Phil" wrote in message
...
My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Inserting Rows

Thanks!

Regards,
Tom Ogilvy

"Paul B" wrote in message
...
Tom, tested in '97 works fine

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **

"Tom Ogilvy" wrote in message
...
Sub Tester10()
Set rng = Cells(5, 1)
For i = 9 To 1000 Step 4
If IsEmpty(Cells(i, 1)) Then Exit For
Set rng = Union(rng, Cells(i, 1))
Next
If Not rng Is Nothing Then
rng.EntireRow.Insert
End If
End Sub

Tested in Excel 2000. Not sure it would work in xl97, but haven't

tested
there. Should work in xl2000 and later I would think.

--
Regards,
Tom Ogilvy


"Phil" wrote in message
...
My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Inserting Rows


-----Original Message-----
My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?


.
c=1

do until isempty(range("a" & c)) = true
c=c+1
loop

for y=1 to c step 4
columns(y).select
seltion.insert shift:=xldown
next y

have a play around with that, you may need to alter it
slightly.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Inserting Rows

Phil,

This code is dependent on column A having something in all cells.
It will loop until it finds a blank cell.
It places the first insert after the 5th row (includes header) and than
separates groups into 4 rows each. Does over 500 rows almost
instantaneously in Excel97.

Application.ScreenUpdating = False ' prevents flicker, speeds it up
Dim x As Long
x = 6
Do Until Cells(x, 1) = ""
Rows(x).Insert
x = x + 5
Loop
Application.ScreenUpdating = True
--
sb
"Phil" wrote in message
...
My worksheet has the following headings:

RegNo FirstName LastName Country Registered


The sheet has over 500 rows of data. Can anyone suggest a
macro that would allow me to insert a blank row after
every 4 lines of data?




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 rows inbetween rows of data ? Azeem Excel Discussion (Misc queries) 1 October 27th 09 07:38 AM
Inserting rows Raynelle Excel Discussion (Misc queries) 1 November 5th 08 08:03 PM
Copying & Inserting Rows w/o Affecting other Rows Etc. LRay67 Excel Worksheet Functions 1 October 22nd 08 02:10 AM
Inserting Blank rows after every row upto 2500 rows Manju Excel Worksheet Functions 8 August 22nd 06 12:54 PM
Inserting rows Luke Excel Worksheet Functions 2 September 17th 05 06:11 PM


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