Consulting

Results 1 to 3 of 3

Thread: Solved: Cells vs Range

  1. #1
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location

    Solved: Cells vs Range

    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?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Thanks. Makes sense.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •