#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Macro to add row

I have a file that I will open on a weekly basis. I want it to create a
macro that will insert a blank row in between all rows. The number of rows
will vary weekly. Please help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 93
Default Macro to add row

This should do you

Sub main()
Dim myRow As Long
Dim lastCell As Long
myRow = 1 'first row to start on
lastCell = Cells(Rows.Count, "A").End(xlUp).Row

For i = lastCell To myRow Step -1
Cells(i, 1).Select
Selection.EntireRow.Insert Shift:=xlDown
Next

End Sub


--
--
-John
Please rate when your question is answered to help us and others know what
is helpful.

"nazzoli" wrote in message
...
I have a file that I will open on a weekly basis. I want it to create a
macro that will insert a blank row in between all rows. The number of
rows
will vary weekly. Please help.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Macro to add row

Thanks works great

"John Bundy" wrote:

This should do you

Sub main()
Dim myRow As Long
Dim lastCell As Long
myRow = 1 'first row to start on
lastCell = Cells(Rows.Count, "A").End(xlUp).Row

For i = lastCell To myRow Step -1
Cells(i, 1).Select
Selection.EntireRow.Insert Shift:=xlDown
Next

End Sub


--
--
-John
Please rate when your question is answered to help us and others know what
is helpful.

"nazzoli" wrote in message
...
I have a file that I will open on a weekly basis. I want it to create a
macro that will insert a blank row in between all rows. The number of
rows
will vary weekly. Please help.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Macro to add row

No need to select, inefficient and wasteful


Sub main()
Dim myRow As Long
Dim lastCell As Long
Dim i As Long
myRow = 1 'first row to start on
lastCell = Cells(Rows.Count, "A").End(xlUp).Row

For i = lastCell To myRow Step -1
Rows(i + 1).Insert
Next

End Sub



--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"John Bundy" wrote in message
...
This should do you

Sub main()
Dim myRow As Long
Dim lastCell As Long
myRow = 1 'first row to start on
lastCell = Cells(Rows.Count, "A").End(xlUp).Row

For i = lastCell To myRow Step -1
Cells(i, 1).Select
Selection.EntireRow.Insert Shift:=xlDown
Next

End Sub


--
--
-John
Please rate when your question is answered to help us and others know what
is helpful.

"nazzoli" wrote in message
...
I have a file that I will open on a weekly basis. I want it to create a
macro that will insert a blank row in between all rows. The number of
rows
will vary weekly. Please help.





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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


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