View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Is really the default property consistently returned/assigned?

I never rely on the default method, partly because I'm anal and partly
because I want to be unambiguous. And partly because it does not always
work as it 'should'. See:

Sub Works()
Sheets("Sheet1").Range("B1:B2").Clear
Sheets("Sheet1").Range("B1:B2").Value = _
Sheets("Sheet2").Range("A1:A2").Value
End Sub

Sub NoWork()
Sheets("Sheet1").Range("B1:B2").Clear
Sheets("Sheet1").Range("B1:B2") = _
Sheets("Sheet2").Range("A1:A2")
End Sub


--
Jim
"Stefano Gatto" wrote in message
...
|I wrote a procedure a bit like this:
|
| For Each rngCell in rngEmployees
| lstEmployees.Additem rngCell
| Next rngCell
|
| rngEmployees is a one-column range filled with employee's names.
|
| This code is trivial and I have been doing it for 10 years without
problems.
| Today for the first time a colleague executing this piece of code calls me
| and shows me that an error is raised with the .Additem method (Type
| mismatch). The debugger says rngCell is definitely a string (like "Joe
| Smith"), not a number, nor anything else.
|
| The strange thing is that it works well on my computer.
|
| When I change
| lstEmployees.Additem rngCell
| into
| lstEmployees.Additem rngCell.Value
|
| then it works on both computers.
|
| Can someone explain me this? Isn't it that .value is the default property
of
| the Range class?
|
| I am really really lost!
|
| Many thanks and have a good day.
|
| Stefano Gatto