Cell() syntax for multi-cell ranges

John Kauffman

New Member
Joined
Oct 13, 2011
Messages
23
Can someone help with the syntax for Cell() for a multi-cell range?

Range(A1) is expressed as Cells(1,1)
Range(A1:B2) is expressed how in Cells()?

Thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
John Kauffman,


Range(A1:B2) is expressed how in Cells()?


Try:
Range(Cells(1,1),Cells(2,2))
 
Last edited:
Upvote 0
Try
Code:
Range(Cells(1,1),Cells(2,2))
 
Upvote 0
or
Code:
Cells(1).Resize(2, 2)
or
Code:
Range(Cells(1), Cells(Columns.Count + 2))
really depends on how you want to subsequently use it
 
Upvote 0
Hiker; Thanks for the help. Range(Cell(1,1),Cell(2,2)) works fine.

I was hoping there would be a solution with just Cell(). The RC values are hard-coded (not variables) so it works to use Range() by itself.

I wanted to use Cell() instead of Range() for two reasons.
- The surrounding lines of code I'm using Cell() and I thought consistency would be good
- I never had reason to think about it before and want to know if possible.

If anyone knows a technique to ref a multi-cell range with just Cell(), I'm all ears.

Much Thanks.
 
Upvote 0
if you like you can try these sorts of code
Code:
Sub xxx()
Dim cell(0)
Set cell(0) = cells.Resize(3, 5).Offset(4, 2)

cell(0).Select

End Sub
or
Code:
Sub yyy()
cells().Resize(2, 4).Select
End Sub
or similar.

But ??? :confused: :coffee:
 
Upvote 0
I was hoping there would be a solution with just Cell(). The RC values are hard-coded (not variables) so it works to use Range() by itself.

I wanted to use Cell() instead of Range() for two reasons.
- The surrounding lines of code I'm using Cell() and I thought consistency would be good
- I never had reason to think about it before and want to know if possible.

Hi John,

If the cell reference is hard-coded as you say it is, the simplicity and clarity of a reference like Range("A1:B2") or [A1:B2] is hard to improve upon.

If you are wanting to be more consistent with the surrounding code, you might consider using Alpha references for the columns in that surrounding code IE:
Cells(1,"A")
 
Upvote 0
Thanks to all, you provided some great ideas.

It seems Cell() has no strict analogy to Range("A1:B2") like Cell(1,1:2,2). That satisfied my curiosity.

You have provided several ways to do the same job, and that satisfied my need.

Much thanks.
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top