try to use a worksheet object
The Sheets collection contains 2 kinds of distinct objects: Worksheets and
Charts (or "Chart Sheets": don't confuse Chart Sheets with Chart objects
that can also exist on Worksheets.).
Example 1 doesn't work because you defined your object variable explicitly
as a worksheet and then tried to assign (what I assume is) a Chart sheet to
it. A pure and simple Type Mismatch.
Your 2nd example works because it avoids the Worksheet vs.Chart sheet issue
and simply points to a member of the Sheets collection.
--
HTH,
George Nicholson
Remove 'Junk' from return address.
"DataDude" wrote in message
...
I must be missing a concept here.
Why does this not work:
Dim FY As String
Dim chartsheet as worksheet
Set ChartSheet = Sheets("PORChart")
FY = ChartSheet.txtFY
When this does work:
Dim FY As String
FY = Sheets("PORChart").txtFY
Call code is executed form a separate code module.
Any explanation would be great.
Thanks
|