Select statement or me?
It's always a good idea to qualify your ranges and objects. You'll never have
to worry about simple changes (like copying from one module to another) breaking
your code.
If the ranges/objects belong to the sheet that owns the code, you can use the Me
keyword. I wouldn't refer to the worksheet name or even the codename. Those
can change and break the code.
In fact, if you're like me, you may find that you copy|paste from working
procedures and reuse the code in other locations. Using the Me keyword and
pasting into a worksheet module will keep the code as-is.
If you use the with/end with structure, like:
with worksheets("somesheetnamehere")
You'll only have to modify the code in that one spot.
In fact, I'd use:
Dim wks as worksheet
....
set wks = worksheets("somesheetnamehere")
....
with wks
...
end with
It would make it even easier to modify.
tony wrote:
<<snipped
- Show quoted text -
Ah! So you're saying that if I want to reference the sheet currently
being worked in I should use the Me. identifyer, as the other way may
confuse the issue. What if - as in this case - the referenced sheet is
the same sheet as that being worked upon. I would have thought this
would have the same result?
Also please accept my apologies for the random words in the last post,
for 'expect' read 'except' and 'cell to be on' should read 'cell to be
of'.
--
Dave Peterson
|