Consulting

Results 1 to 4 of 4

Thread: Solved: What's the difference?

  1. #1
    VBAX Regular
    Joined
    Mar 2005
    Posts
    50
    Location

    Solved: What's the difference?

    Friends,

    Please, tell me, what's the difference between...

    Sheets("Sheet1").Cells(1, 1).Select and Worksheets("Sheet1").Range("A1").Select ???

    Which is better to use? Are there specific cases we should use one or other?

    Thanks for your attention.

    Brunces

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Sheets("Sheet1") vs. Worksheets("Sheet1")
    The Sheets collection includes both worksheets (cells) and chart sheets.
    The Worksheets collection does not include chart sheets.
    Sheets.Count >= Worksheets.Count
    If you don't use charts, Sheets is shorter to type.


    Range("a1") vs. Cells(1,1)
    Range is good for when I don't remember wheter M is 13th letter or the 14th.
    For looping, Cells is better (IMO). I find it easier to read
    Cells(rowNumber,13)
    than
    Range("M" & row)
    The two argument Range is very useful
    Range(Range("a1"),Range("b2")) = Range("a1:b2")
    Does that help?

  3. #3
    VBAX Regular
    Joined
    Mar 2005
    Posts
    50
    Location
    Yup! Thank you very much, mikerickson.

  4. #4
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    That does help mikerickson. Concise and easy to understand
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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