ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fastest way to reference a particular cell? (https://www.excelbanter.com/excel-programming/412760-fastest-way-reference-particular-cell.html)

Maury Markowitz[_2_]

Fastest way to reference a particular cell?
 
Is there any "best way" to access the contents of a cell? IE, is there
any real difference between...

ActiveSheet.Cells(i,j)

or

ActiveSheet.Range("AB" & i)

Maury

Don Guillett

Fastest way to reference a particular cell?
 
Not really

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Maury Markowitz" wrote in message
...
Is there any "best way" to access the contents of a cell? IE, is there
any real difference between...

ActiveSheet.Cells(i,j)

or

ActiveSheet.Range("AB" & i)

Maury



Jim Thomlinson

Fastest way to reference a particular cell?
 
Genearlly speaking I concur with Don in that there is no difference in what
you have posted...

Cells referes to a single cell where as range can refer to a group of cells.
Since there are differences though I do tend to use them under different
circumstances.

When I want a single cell referenced by some kind of variable I use Cells.
So in your example I would use Cells something like this
Cells(i, "AB")
I find createing a concatenated string to be awkward and at time error prone.

I tend to use range when the Cell reference is hard coded such as
Range("A1")
As I find that easier to read. I also use it when I need a range of cells
like this
=range(range("A1"), cells(i, "AB"))

That is my personal preference. The best thing that I can recommend is to be
consistent. It will make your code easier to read and understand.

--
HTH...

Jim Thomlinson


"Maury Markowitz" wrote:

Is there any "best way" to access the contents of a cell? IE, is there
any real difference between...

ActiveSheet.Cells(i,j)

or

ActiveSheet.Range("AB" & i)

Maury



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

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