Insert Mult. Rows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a macro that a user can insert a row or rows based on
input boxes at any desired row. The code I have put together is below (there
is more to it than this but this is the base).

The problem is with the line,
Rows("InsertRow:EndRow").Select
It errors out. Any suggestions would be appreciated.
I am using Excel 97.

Dim InsertRow As Integer
Dim NumberOfRows As Integer
Dim EndRow As Integer

InsertRow = InputBox("Enter the Row Number where you want to Insert the
row.")
NumberOfRows = InputBox("Enter how many Rows you want to Insert.")
EndRow = InsertRow + NumberOfRows

Rows("InsertRow:endrow").Select
Selection.Insert Shift:=xlDown


appeng
 
Try the following:

Dim InsertRow As Integer
Dim NumberOfRows As Integer
Dim EndRow As Integer

InsertRow = InputBox("Enter the Row Number where you want to
Insert the row.")
NumberOfRows = InputBox("Enter how many Rows you want to
Insert.")
EndRow = InsertRow + NumberOfRows
Rows(InsertRow).Resize(NumberOfRows).Insert



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top