The way to do this is to add a ".value" at the end of the range. Itβs usually a good idea to make things very explicit (the reason you can omit this is because the value is the default property for the range object)
I added all the values ββin the clock to see what was happening, and apparently the Excel problem was not able to efficiently (and implicitly) drop the object on the fly. Notice how the expression that fails "ActiveSheet.Range (" A1: A10 ") is of type: Variant / Object / Range; switching from a variant to an object is most likely causing a problem.

The way to force the correct display will be to divide the process into two parts, which the first selects for the range, and the second into the variant array. Look at my example
Also note that if you declare a variable only as an option, and not an array of options (dim E, not dim E ()), it will receive it because it will adapt to what is needed.
Sub tuEs() 'Works Dim A() As Variant A = Range("A1:A10") ' Type missmatch Dim B() As Variant B = ActiveSheet.Range("A1:A10") ' Fix to make it cast properly Dim C() As Variant Dim r As Range Set r = ActiveSheet.Range("A1:A10") C = r ' Best of all options Dim d As Variant d = ActiveSheet.Range("A1:A10").Value End Sub
Hope this is somewhat clear.
user5412293
source share