ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to add one column to a range VBA (https://www.excelbanter.com/excel-programming/366661-how-add-one-column-range-vba.html)

in-over-his-head-bill

How to add one column to a range VBA
 
Sorry to be so thick, but I am really struggling with how to correctly
specify ranges.
I dumped a recordset (which will have varying sizes in my application) onto
a worksheet beginning at cell A25. What I want to do is have a named range
for the results I put on the worksheet plus one additional column.

I've got the getting the results into the range down with the code below.
How do I get an extra column into the range?

Dim rng As Range
Set rng =
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegion
rng.Name = "reportcontrol"


Ardus Petus

How to add one column to a range VBA
 
Dim rng As Range
Set rng =
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegion
set rng=rng.resize(rng.rows+1)
rng.Name = "reportcontrol"

"in-over-his-head-bill" a
écrit dans le message de news:
...
Sorry to be so thick, but I am really struggling with how to correctly
specify ranges.
I dumped a recordset (which will have varying sizes in my application)
onto
a worksheet beginning at cell A25. What I want to do is have a named range
for the results I put on the worksheet plus one additional column.

I've got the getting the results into the range down with the code below.
How do I get an extra column into the range?

Dim rng As Range
Set rng =
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegion
rng.Name = "reportcontrol"




Bob Phillips

How to add one column to a range VBA
 
Set rng = _
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegio
n
Set rng = rng.Resize(, rng.Columns.Count + 1)
rng.Name = "reportcontrol"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"in-over-his-head-bill" wrote
in message ...
Sorry to be so thick, but I am really struggling with how to correctly
specify ranges.
I dumped a recordset (which will have varying sizes in my application)

onto
a worksheet beginning at cell A25. What I want to do is have a named range
for the results I put on the worksheet plus one additional column.

I've got the getting the results into the range down with the code below.
How do I get an extra column into the range?

Dim rng As Range
Set rng =

Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegio
n
rng.Name = "reportcontrol"




Don Guillett

How to add one column to a range VBA
 
try
toright).offset(,1)

--
Don Guillett
SalesAid Software

"in-over-his-head-bill" wrote
in message ...
Sorry to be so thick, but I am really struggling with how to correctly
specify ranges.
I dumped a recordset (which will have varying sizes in my application)
onto
a worksheet beginning at cell A25. What I want to do is have a named range
for the results I put on the worksheet plus one additional column.

I've got the getting the results into the range down with the code below.
How do I get an extra column into the range?

Dim rng As Range
Set rng =
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegion
rng.Name = "reportcontrol"




in-over-his-head-bill

How to add one column to a range VBA
 
Thanks to you both for getting me through the mental block.

"Bob Phillips" wrote:

Set rng = _
Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegio
n
Set rng = rng.Resize(, rng.Columns.Count + 1)
rng.Name = "reportcontrol"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"in-over-his-head-bill" wrote
in message ...
Sorry to be so thick, but I am really struggling with how to correctly
specify ranges.
I dumped a recordset (which will have varying sizes in my application)

onto
a worksheet beginning at cell A25. What I want to do is have a named range
for the results I put on the worksheet plus one additional column.

I've got the getting the results into the range down with the code below.
How do I get an extra column into the range?

Dim rng As Range
Set rng =

Worksheets("programws").Range("A25").End(xlDown).E nd(xlToRight).CurrentRegio
n
rng.Name = "reportcontrol"






All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com