ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting ranges with Cells() (https://www.excelbanter.com/excel-programming/388495-selecting-ranges-cells.html)

robotman

Selecting ranges with Cells()
 
Can someone tell me how to specify a range with the Cells command?

On the spreadsheet level, you can use OFFSET to not only specify the
offset cell starting point, but also how many cells across and down
you'd like to reference. (i.e. "=OFFSET(A1,0,0,1,5)")

In VBA, the Offset only seems to let you specify the offset cell.

I'd like to be able to specify a range with a single Cells command
like:

Cells(1,1).Offset(0,0,1,5).Select ' Select A1:E1

What syntax would I use to designate a range using Cells?

Thanks!

John


Norman Jones

Selecting ranges with Cells()
 
Hi Robotman,


Try:

Set Rng = Range("A1").Resize(1,5)


---
Regards,
Norman




"robotman" wrote in message
ups.com...
Can someone tell me how to specify a range with the Cells command?

On the spreadsheet level, you can use OFFSET to not only specify the
offset cell starting point, but also how many cells across and down
you'd like to reference. (i.e. "=OFFSET(A1,0,0,1,5)")

In VBA, the Offset only seems to let you specify the offset cell.

I'd like to be able to specify a range with a single Cells command
like:

Cells(1,1).Offset(0,0,1,5).Select ' Select A1:E1

What syntax would I use to designate a range using Cells?

Thanks!

John




Jim Thomlinson

Selecting ranges with Cells()
 
You really want to use a range to do what you are asking something like this...

Range(cells(1,1), cells(2,6)).Select
or
Range(cells(1,1), cells(1,1).Offset(1,5)).Select
--
HTH...

Jim Thomlinson


"robotman" wrote:

Can someone tell me how to specify a range with the Cells command?

On the spreadsheet level, you can use OFFSET to not only specify the
offset cell starting point, but also how many cells across and down
you'd like to reference. (i.e. "=OFFSET(A1,0,0,1,5)")

In VBA, the Offset only seems to let you specify the offset cell.

I'd like to be able to specify a range with a single Cells command
like:

Cells(1,1).Offset(0,0,1,5).Select ' Select A1:E1

What syntax would I use to designate a range using Cells?

Thanks!

John



robotman

Selecting ranges with Cells()
 
Thanks for the syntax ideas.

Why do you think I need to use Range()?

Currently I use the double Cells() in the Range() command, but this
seems very clunky. I'm trying to simply the code by not needing the
double Cells() commands. I'll try Resize to see if that gives me full
functionality when selecting a range. I'm guessing it has
limitations.

Any other ideas to simply range selections with out using letter (i.e.
"A1") cell-referencing?









All times are GMT +1. The time now is 03:24 AM.

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