![]() |
Need the code for a simple macro
I have looked on the internet and through a couple forums for code to
insert a new row in every other row of a spreadsheet, I work with a lot of data and sometimes the people above me will delete out the empty rows and it makes spacing off so i cannot copy and paste anything out of it and it gets old pasting adjusting 6000 excel rows and such.......I just need a macro that i can click on a cell and it will insert a row under it and from there down in every other row until an end row that i specify.....thanx Durst *** Sent via Developersdex http://www.developersdex.com *** |
Need the code for a simple macro
Why do you need the empty rows?
If just for appearance, your life may be easier if you just delete them and set the row heights to double the height. But................ Sub InsertALTrows() 'David McRitchie, misc 2001-06-30 Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim I As Integer For I = Selection(Selection.Count).Row To Selection(1).Row + 1 Step -1 Rows(I).EntireRow.Insert Next I Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub Select the rows you want then run the macro using a button or shortcut key combo. Gord Dibben MS Excel MVP On Thu, 21 Jun 2007 14:15:31 -0700, VB MacroMan wrote: I have looked on the internet and through a couple forums for code to insert a new row in every other row of a spreadsheet, I work with a lot of data and sometimes the people above me will delete out the empty rows and it makes spacing off so i cannot copy and paste anything out of it and it gets old pasting adjusting 6000 excel rows and such.......I just need a macro that i can click on a cell and it will insert a row under it and from there down in every other row until an end row that i specify.....thanx Durst *** Sent via Developersdex http://www.developersdex.com *** |
Need the code for a simple macro
If you really need it something like this should do it:
Sub InsertEmptyRows() Dim r1 As Range Dim r2 As Range Dim i As Integer Set r1 = Application.Selection For i = r1.Rows.Count To 2 Step -1 Set r2 = r1.Rows(i).EntireRow r2.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Next End Sub TZS "VB MacroMan" schrieb im Newsbeitrag ... I have looked on the internet and through a couple forums for code to insert a new row in every other row of a spreadsheet, I work with a lot of data and sometimes the people above me will delete out the empty rows and it makes spacing off so i cannot copy and paste anything out of it and it gets old pasting adjusting 6000 excel rows and such.......I just need a macro that i can click on a cell and it will insert a row under it and from there down in every other row until an end row that i specify.....thanx Durst *** Sent via Developersdex http://www.developersdex.com *** |
Need the code for a simple macro
Worked amazingly thanx guys.............
Durst *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 05:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com