#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Adding Rows

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Adding Rows

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

--
Regards,
Tom Ogilvy


"JohnUK" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Adding Rows

Many thanks Tom - you done it again

Regards
John

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"JohnUK" wrote:

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

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
Adding rows James Excel Discussion (Misc queries) 5 December 31st 08 07:53 PM
Adding rows based on no of rows specified from a given position nanette Excel Worksheet Functions 1 July 9th 08 02:29 PM
Adding five new rows every 40 rows in a spreadsheet? Olzki Excel Discussion (Misc queries) 8 May 18th 07 02:14 AM
Adding Rows offsets to working rows across two worksheets tom Setting up and Configuration of Excel 3 July 30th 06 07:54 PM
Adding New Rows in VBA Captainski009 Excel Programming 1 September 2nd 04 10:53 PM


All times are GMT +1. The time now is 08:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"