PDA

View Full Version : Solved: What's the difference?



brunces
06-27-2007, 04:05 PM
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

mikerickson
06-27-2007, 04:56 PM
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?

brunces
06-27-2007, 05:02 PM
Yup! Thank you very much, mikerickson. :)

lucas
06-27-2007, 08:25 PM
That does help mikerickson. Concise and easy to understand