xcel 2000 Vs xcel97

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi everyone!
Is this expression not supported in xcel '97

<font face=Courier New>        <SPAN style="color:#00007F">Set</SPAN> X1 = Worksheets("Training Log").Range("C" & FIRST & ":C" & LAST)
            TMP = X1.Value
            Worksheets("90R Data").Range("B2:B91") = TMP</FONT>

this works fine in 2000. But I got a feed back that he
gets and error of

Code:
"Compile Error: Can't assign to Array"


thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Colo

MrExcel MVP,
Joined
Mar 20, 2002
Messages
1,456
Hi SIXTH SENSE,

I think it works in 97. In this case a variable named TMP should be a Variant type.
In your code, since the declaration part was omitted so a variable TMP has been treated as Variant type.
k, to make sure the problem I'll re-write your code as simple one.

Code:
Sub TEST()
    Dim X1 As Range
    Dim TMP As Variant
    Set X1 = Worksheets(1).Range("A1:A10")
    TMP = X1.Value
    Worksheets(1).Range("B1:B10").Value = TMP
End Sub
 

NateO

Legend
Joined
Feb 17, 2002
Messages
9,700
Agreeing with Colo, this is going to be true of any quick-stacked array eh, e.g.,

<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> Quick_Stack()
<SPAN style="color:darkblue">Dim</SPAN> myArr1 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>, myArr2 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>, myArr3 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>
myArr1 = Array(1, 2, 3)
myArr2 = [{1,2,3}]
myArr3 = [Transpose(Offset(O11,(Row(1:5)-1)*7+1,0,1,3))]
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> myArr3(UBound(myArr3)).Address
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
Colo said:
Hi SIXTH SENSE,

I think it works in 97. In this case a variable named TMP should be a Variant type.
In your code, since the declaration part was omitted so a variable TMP has been treated as Variant type.
k, to make sure the problem I'll re-write your code as simple one.

Code:
Sub TEST()
    Dim X1 As Range
    Dim TMP As Variant
    Set X1 = Worksheets(1).Range("A1:A10")
    TMP = X1.Value
    Worksheets(1).range("B1:B10").Value = TMP
End Sub


Thanks colo.

I declare the variable tmp as

Code:
       dim tmp()

which I think by difualt is variant!
Is it something different from

Code:
      dim tmp as variant

TY.
 

Colo

MrExcel MVP,
Joined
Mar 20, 2002
Messages
1,456
SIXTH SENSE said:
Thanks colo.

I declare the variable tmp as

Code:
       dim tmp()

which I think by difualt is variant!
Is it something different from

Code:
      dim tmp as variant

TY.

Hi, SS!

It's different. TMP() is treated as an array/variant.

Code:
Sub Test1()
    Dim TMP()
    Debug.Print TypeName(TMP)
    Debug.Print IsArray(TMP)
End Sub

Sub Test2()
    Dim TMP
    Debug.Print TypeName(TMP)
    Debug.Print IsArray(TMP)
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,160
Messages
5,768,537
Members
425,480
Latest member
br400821

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top