Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Append new row of data to range

Say you have a rectangular range named rngData on your
worksheet, and you want to add a new row of data to the
bottom, expanding rngData accordingly. What's the most
straightforward way to do this in code?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Append new row of data to range

Art,

Try something like

With Range("rngData")
.Cells(.Cells.Count + 1).EntireRow.Insert xlDown
ThisWorkbook.Names.Add "rngData", .Resize(.Rows.Count + 1)
End With


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


"Art" wrote in message
...
Say you have a rectangular range named rngData on your
worksheet, and you want to add a new row of data to the
bottom, expanding rngData accordingly. What's the most
straightforward way to do this in code?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Append new row of data to range

Assume rngData is a variable of type Range
set rngData = rngData.Resize(rngdata.rows.count+1)

Assume rngData is a defined name

set rng = Range("rngData")
rng.Resize(rng.rows.count+1).Name = "rngData"

Demo'd from the immediate window:

set rngData = Range("A1:Z26")
set rngData = rngData.Resize(rngdata.rows.count+1)
? rngData.Address
$A$1:$Z$27


Range("A1:Z26").Name = "rngData"
set rng = Range("rngData")
rng.Resize(rng.rows.count+1).Name = "rngData"
? Range("rngData").Address
$A$1:$Z$27

--
Regards,
Tom Ogilvy






Art wrote in message
...
Say you have a rectangular range named rngData on your
worksheet, and you want to add a new row of data to the
bottom, expanding rngData accordingly. What's the most
straightforward way to do this in code?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Thanks again Tom!


-----Original Message-----
Assume rngData is a variable of type Range
set rngData = rngData.Resize(rngdata.rows.count+1)

Assume rngData is a defined name

set rng = Range("rngData")
rng.Resize(rng.rows.count+1).Name = "rngData"

Demo'd from the immediate window:

set rngData = Range("A1:Z26")
set rngData = rngData.Resize(rngdata.rows.count+1)
? rngData.Address
$A$1:$Z$27


Range("A1:Z26").Name = "rngData"
set rng = Range("rngData")
rng.Resize(rng.rows.count+1).Name = "rngData"
? Range("rngData").Address
$A$1:$Z$27

--
Regards,
Tom Ogilvy






Art wrote in message
...
Say you have a rectangular range named rngData on your
worksheet, and you want to add a new row of data to the
bottom, expanding rngData accordingly. What's the most
straightforward way to do this in code?




.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Append new row of data to range


-----Original Message-----
Say you have a rectangular range named rngData on your
worksheet, and you want to add a new row of data to the
bottom, expanding rngData accordingly. What's the most
straightforward way to do this in code?


.Type it in

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
Append Data From Two Files KD Excel Discussion (Misc queries) 0 April 1st 09 08:51 PM
append column data ACarella Excel Worksheet Functions 3 July 22nd 08 06:13 PM
append worksheet with data from another Mark B Excel Worksheet Functions 3 May 8th 08 06:19 PM
how do i append old and new data in excel pauloz Excel Worksheet Functions 1 November 10th 07 05:47 PM
Auto append data Dan S. Excel Discussion (Misc queries) 1 March 23rd 07 06:23 AM


All times are GMT +1. The time now is 06:26 PM.

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

About Us

"It's about Microsoft Excel"