Append new row of data to range

  • Thread starter Thread starter Art
  • Start date Start date
A

Art

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?
 
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 (e-mail address removed)
 
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
 
-----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









.
 
-----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
 
Back
Top