Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just to add...
When you use: foo = range("A1") it's the equivalent of: foo = range("A1").value Foo is just a plain old value (string, number, ...) In your case, foo = range(cells(1,1), cells(1,2)) it's the equivalent of: foo = range(cells(1,1), cells(1,2)).value Foo is a 1 row by 2 column array of values. When/if you use Set, then foo will be a range object (since you're working with a Range. It'll have all the nice properties of ranges and be able to use all the methods of ranges, too. On 09/02/2011 08:09, Walter Briscoe wrote: I am running VBA 6.5 from Excel 2003. I have a line like Foo = Range(Cells(1, 1), Cells(1, 2)) If Foo is declared with Dim Foo As Variant, the line runs without error. If Foo is declared with Dim Foo As Range, I get "Run-time error '91'; Object variable or With block variable not set". I can fix the assignment by prefixing it with Set to read Set Foo = Range(Cells(1, 1), Cells(1, 2)) Why does a variant not need Set and a compatible object needs set? I don't imagine anyone outside Microsoft can give the reason for such errors not being detected at compilation time. ;) [I am in the middle of eliminating Variant, where possible in a fairly large file. I have already applied early binding where possible] -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using created variant value to reference to a variant within my code | Excel Programming | |||
Variant | Excel Programming | |||
Variant/Double?!? | Excel Programming | |||
Passing value of variant | Excel Programming | |||
Variant | Excel Programming |