View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
IanC[_2_] IanC[_2_] is offline
external usenet poster
 
Posts: 157
Default Worksheet or Me. Why the difference?

Hi Jon

No coincidence whatsoever! That was the problem. Now sorted.

Many thanks.

--
Ian
--

"Jon Peltier" wrote in message
...
All the lines you've marked as failed have an extra set of parentheses
around the range. Coincidence?

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
774-275-0064
http://peltiertech.com/


On 9/9/2010 2:52 PM, IanC wrote:
Hi Bob

I thought that should be the case. All the names ranges are on the Lookup
sheet and referenced as such, but it's wierd that some apply correctly
and
others fail. I can't see what the difference is.

Oh well. It looks like I'll have to be happy sticking with
Worksheets("Checklist").

--
Ian
--
"Bob wrote in message
...
It should apply to them all if they are ranges within that worksheet, if
another worksheet then they won't apply.

--

HTH

Bob

wrote in message
...
Hi Bob

Thanks for the response.

The code is contained in the worksheet, so Me should equate to
Worksheets("Checklist") and appears to in some cases. I can't
understand
why it works for some named ranges, but not others.

Any ideas?

--
Ian
--

"Bob wrote in message
...
You can only use Me when there is a containing object (Me) in
question,
such
as in Userform code (Me if the form), in ThisWorkbook code module (Me
is
the
workbook), or in a worksheet code module (Me is the worksheet).

--

HTH

Bob

wrote in message
...
I have some code which is confusing me. The code copies some named
ranges
from Lookup to specific locations on Checklist.

This code works fine:

With Worksheets("Checklist")
[Lookup!InstruSoftware].Copy .Range("I2")
[Lookup!TubeCount].Copy .Range("U3")
[Lookup!Alpha_kV].Copy .Range("A6")
[Lookup!Alpha_AEC].Copy .Range("A18")
[Lookup!Alpha_Errors].Copy (.Range("O6")) 'xxxx
[Lookup!AlphaAlignment].Copy .Range("Y6")
[Lookup!Alpha_Mechanical].Copy (.Range("Y15")) 'xxxx
[Lookup!Alpha_Electrical].Copy (.Range("Y30")) 'xxxx
[Lookup!Alpha_Earthing].Copy (.Range("O28")) 'xxxx
End With

If I change Worksheets("Checklist") to Me, I get an error for each of
the
marked lines. The error is "Run-time error '1004': Copy method of
Range
class failed".

The destination sheet is unprotected and there are no merged cells in
the
destination ranges.

Can anyone explain why there is this difference between using Me and
the
sheet name?

--
Ian
--