Adding Rows

J

JohnUK

Having some great help from
Tom Ogilvy & Bob Phillips - I need to go a step further with regards to
inserting X amount of rows after the last piece of data. The code I have so
far:

Const NUM_ROWS As Long = 20
Dim iLastRow As Long
iLastRow = Cells(Rows.count, "N").End(xlUp).Row
Rows(iLastRow + 1).Resize(NUM_ROWS)

Because the number of rows would change constantly, I am trying to get the
code to look up a range. My poor attempt:

Rows = Range("Number").Value
Const NUM_ROWS As Long = " & Rows & "
Dim iLastRow As Long
iLastRow = Cells(Rows.count, "N").End(xlUp).Row
Rows(iLastRow + 1).Resize(NUM_ROWS).Insert


Can someone put me back on the right path?
Regards
John
 
T

Tom Ogilvy

If the named range "Number" contains the number of rows to insert, then:

Dim iLastRow As Long, rws as Long
rws = Range("Number").Value
iLastRow = Cells(Rows.count, "N").End(xlUp).Row
Rows(iLastRow + 1).Resize(rws).Insert
 

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

Similar Threads


Top