Excel 2010 Insert Rows and Move Data

I have an Excel workbook of approximately 1500 rows with data in columns A and B.  I need to insert a row and move the data in column B to the row that was recently inserted. Next I need to insert another row so that there is a blank row between two rows with data.

Is there a VBA procedure a macro that could do this for me?

Thanks for your help,

Jeremy


Excel 2010 Insert Rows and Move Data

I have an Excel workbook of approximately 1500 rows with data in columns A and B.  I need to insert a row and move the data in column B to the road that was recently inserted. Next I need to insert another row so that there is a blank row between two rows with data.

Is there a VBA procedure a macro that could do this for me?

Thanks for your help,

Jeremy
Jeremy-MAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FlysterCommented:
Try this macro. I believe it will give you the results you're looking for. As always, with trying any macro the first time, be sure to have a backup of your data available :)

Flyster
Sub AddRows()
Dim LstRow As Integer
Dim Ctr As Integer


LstRow = Range("A65536").End(xlUp).Row * 3

  For Ctr = 2 To LstRow Step 3
     Rows(Ctr & ":" & Ctr).Select
     Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
     Range("B" & Ctr - 1).Select
     Selection.Cut
     Range("B" & Ctr).Select
     ActiveSheet.Paste
     Rows(Ctr + 1 & ":" & Ctr + 1).Select
     Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
  Next Ctr

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.