Results/ Conclusions 1 Single Cell in/ out of Evaluate(" ")
Again some Measurements, Results and conclusions with hindsight
Consider the following coding.
Rem 0
Two cells are considered, both are similar numbers, only one of the cells exhibits the Number held as text thing
Rem 1
For a simple single cell range, Evaluate(" ") , seems to return an actual range object, and if we attempt to put that in a cell, it won’t default to taking the default property, .Value, instead it appears to put the range object in. This will preserve the string of a number held as a string, A70 and B70
If it did default to the .Value property, then we would get the result as in C70
Rem 2
If you assign the result from Evaluate(" ") for a simple single cell range, into a variable, then VBA seems to be quite obliging, coercing appropriately to suit the declaration of any reasonable variable type.
If the variable is a Variant, the type held in the Variant will be a string in the case of Evaluate(" ") of a cell exhibiting the number held as text thing.
Rem 3
Any attempt to put a string into a cell won’t give the number held as text thing. Strange.
Code:
Sub SetRangeValueWithSingleCellRangeFromEvaluate() ' https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21979&viewfull=1#post21979
Rem 0
' Test data range
Dim Ws12 As Worksheet: Set Ws12 = ThisWorkbook.Worksheets.Item("Sheet1 (2)")
Ws12.Range("A69:D71").Clear ' .Clear to get rid of all valiues and any formats
Let Ws12.Range("A69").Value = Split("44") ' ' Gives Number held as text thing
Let Ws12.Range("D69").Value = "55" ' does not give "
' https://i.postimg.cc/GHFdY4r3/Two-ce...ne-as-text.jpg
' https://i.postimg.cc/HsKxqMhM/Two-ce...ne-as-text.jpg
Rem 1
' Evalute(" ") from the single cell ranges
Dim VA69 As Variant, VD69 As Variant, RA69 As Range, RD69 As Range
' 1a) Fubdamentally, I think Evalute(" ") returns a range, and it knows what is what
Set RA69 = Evaluate("=A69") ' Watch : + : RA69 : "44" : Range/Range : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Set RD69 = Evaluate("=D69") ' Watch : + : RD69 : 55 : Range/Range : Sheet2.SetRangeValueWithSingleCellRangeFromEval
70 Let Ws12.Range("A70") = Evaluate("=A69") ' This appears to apply the range to a cell ..... and it knows waht is what
Let Ws12.Range("A70") = RA69 ' Watch : + : Ws12.Range("A70") : "44" : Object/Range : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Ws12.Range("B70").Value = RA69 ' Watch : : Ws12.Range("B70").Value : "44" : Variant/String : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Ws12.Range("C70") = RA69.Value ' Watch : + : Ws12.Range("C70") : 44 : Object/Range : Sheet2.SetRangeValueWithSingleCellRangeFromEval
' Watch : : RA69.Value : "44" : Variant/String : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Ws12.Range("D70") = Evaluate("=D69")
Let Ws12.Range("D70") = RD69
Rem 2 Assigning Evalute(" ") to a variable is fairly obliging
Let VA69 = Evaluate("=A69") ' Watch : : VA69 : "44" : Variant/String : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let VD69 = Evaluate("=D69") ' Watch : : VB69 : 55 : Variant/Double : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Dim Str As String, Lng As Long
Let Str = Evaluate("=D69") ' Watch : : Str : "55" : String : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Str = Evaluate("=A69") ' Watch : : Str : "44" : String : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Lng = Evaluate("=A69") ' Watch : : Lng : 44 : Long : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Lng = Evaluate("=D69") ' Watch : : Lng : 44 : Long : Sheet2.SetRangeValueWithSingleCellRangeFromEval
71 Rem 3 Any attempt to put a string into a cell won't give the number held as text thing
Let Ws12.Range("A71").Value = Str
Let Ws12.Range("B71") = Str
Let Ws12.Range("C71") = "45"
72 Rem 4
Dim arrRng(1 To 1) As Range
Set arrRng(1) = Evaluate("=A69") 'Watch : + : arrRng(1) : "44" : Range/Range : Sheet2.SetRangeValueWithSingleCellRangeFromEval
Let Ws12.Range("A72").Value = arrRng(1) ' gives the number held as text thing
Let Ws12.Range("A72").Value = arrRng() ' gives the number held as text thing
Let Ws12.Range("B72") = arrRng(1) ' gives the number held as text thing
Dim arrStr(1 To 1) As String
Let arrStr(1) = "46"
Let Ws12.Range("C72").Value = arrStr(1) ' this DOES NOT gives the number held as text thing
Let Ws12.Range("C72").Value = arrStr() ' gives the number held as text thing
' https://i.postimg.cc/mthCXNPg/Result...xperiments.jpg
' https://i.postimg.cc/c4BhJFZw/Result...xperiments.jpg
End Sub