PDA

View Full Version : Solved: Cells vs Range



Opv
03-16-2011, 06:42 PM
I read somewhere while browsing the Net that one should always use "Range" rather than "Cells" when defining cell references. Can someone please explain why that would be the case?

mdmackillop
03-16-2011, 06:52 PM
Never heard that so I looked and found this.

A lot of VBA beginners start their career using Cells. For example:
Cells(1,1).Select is the same thing as Range("A1").Select and
Cells(11,31).Select is the same as Range("AE11").Select.

We strongly recommend that you use Range instead of Cells to work with cells and groups of cells. It makes your sentences much clearer and you are not forced to remember that column AE is column 31.

It seems a trivial reason and I find Cells(i,j) much more flexible.
BTW j = Cells(1,"AE").Column, so we don't have to remember it.

Opv
03-16-2011, 06:56 PM
Thanks. Makes sense.