View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_2_] Dave Peterson[_2_] is offline
external usenet poster
 
Posts: 420
Default Strange CopyRange behaviour

I don't know the reason, but I do know that specifying the properties you want
and qualifying the ranges you're using are both good programming practices.



On 09/17/2010 18:08, eliano wrote:
On 17 Set, 01:13, Dave wrote:
I think it's just the prime example to specify the property that you want!

On 09/16/2010 06:39, Bruno Campanini wrote:





Range1 and Range2 are multiple-cells ranges.


1 - Range2 = Range1
2 - Range2.Value = Range1
3 - Range2 = Range1.Value
4 - Range2.Value = Range1.Value


Lines 1 and 2 don't copy anything
Lines 3 and 4 copy Range1 over Range2


Instead, if Range1 and Range2 are single-cell ranges,
all lines 1 to 4 copy Range1 over Range2.


That's since Excel 2003 (at least!)


Any comments?


Bruno


--
Dave Peterson- Nascondi testo citato

- Mostra testo citato -


Sorry Dave, but with the first example seems that I cannot have any
copy.

Public Sub test1()
Dim rng1 As Excel.Range
Dim rng2 As Excel.Range

Set rng1 = [a1:a5]
Set rng2 = [b1:b5]

rng1.Value = 1

rng2 = rng1 'First example by Mr.Campanini

End Sub

and I cannot understand the reason.

Regards
Eliano


--
Dave Peterson