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

I'm trying to create a macro in Excel 2002 where, I can
insert two rows between every number in column A:

Column A
1
2
3
4
5
6
7
8
9

Any ideas? Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Inserting Rows Through a Macro

Mike,
Try

Sub insertrows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
Range("A" & i & ":A" & (i + 1)).EntireRow.Insert
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Cecil

"Mike" wrote in message
...
I'm trying to create a macro in Excel 2002 where, I can
insert two rows between every number in column A:

Column A
1
2
3
4
5
6
7
8
9

Any ideas? Thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Inserting Rows Through a Macro

Cecil,
Thanks so much! That worked like a champ. Wondering if
you can help me with the second piece, where I'm trying
to paste formulas into the blank rows i've just
inserted. Again, this would be repeated down the entire
spreadsheet. I've named a range of cells w/formulas that
I'd like to copy "formularange".

Thanks again.
-----Original Message-----
Mike,
Try

Sub insertrows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
Range("A" & i & ":A" & (i + 1)).EntireRow.Insert
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Cecil

"Mike" wrote in message
...
I'm trying to create a macro in Excel 2002 where, I can
insert two rows between every number in column A:

Column A
1
2
3
4
5
6
7
8
9

Any ideas? Thanks in advance.




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Inserting Rows Through a Macro

Mike,
you can try it by adding this line just before Next i
Range("A" & i & ":A" & (i + 1)).Formula = _
Range("formularange").Formula
or this line
Range("formularange").Copy _
Destination:=Range("B" & i)
But I think you need a different approach.
Cecil

"Mike" wrote in message
...
Cecil,
Thanks so much! That worked like a champ. Wondering if
you can help me with the second piece, where I'm trying
to paste formulas into the blank rows i've just
inserted. Again, this would be repeated down the entire
spreadsheet. I've named a range of cells w/formulas that
I'd like to copy "formularange".

Thanks again.
-----Original Message-----
Mike,
Try

Sub insertrows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
Range("A" & i & ":A" & (i + 1)).EntireRow.Insert
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Cecil

"Mike" wrote in message
...
I'm trying to create a macro in Excel 2002 where, I can
insert two rows between every number in column A:

Column A
1
2
3
4
5
6
7
8
9

Any ideas? Thanks in advance.




.



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
Macro auto inserting rows and formulas jjoverfield Excel Discussion (Misc queries) 0 November 13th 08 10:51 PM
Macro Help- Inserting Blank Rows jack Excel Discussion (Misc queries) 3 January 16th 07 09:43 PM
Macro needed for inserting blank rows sunslight Excel Worksheet Functions 2 January 12th 07 05:58 PM
Inserting Blank Rows Macro? Michael Saffer Excel Worksheet Functions 2 November 9th 04 06:23 PM
INSERTING ROWS WITH A MACRO Jay Dean Excel Programming 15 September 16th 03 05:08 PM


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