You could look into it at:
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/comparison-operators
which is concerned with how things happen in VBA, but given that VBA can directly draw upon the cell values without declaring a variable and therefore a type, it presumably is able to decide type from the raw material and move forward.
About 2/3 down the page, one of the tables (not the first that seems to address the subject) has the most "here-applicable" instances of what combinations do.
Essentially, the idea is that if one of the values is a string, the comparison performed will be a string comparison which seems to invoke whatever exact process is used for a sort on cells. So as one would expect when sorting, numeric values will come before string values. Others fit in as well: logical values, nulls, blanks, etc. You will see there are rules VBA uses (and therefore likely cell-side Excel too) so, for instance, a blank will likely be treated as a 0 but a null likely will not depending upon the exact type mismatched.
To avoid the problem, check for text first in another IF()
handling its existence as one needs to do, then perform the ">" comparison. Use ISTEXT()
for instance, or even just:
=IFERROR(IF(A1,"True value","False value"),"Non-numerical value present")
It would work for your exact use because you are testing for a number not requalling 0. In the above IF()
test, Excel looks at A1 and performs a logical
test only: a 0 is FALSE
and any other numerical value at all is TRUE
which is the same as your A1>0 test. So if it is other than 0, you get "True value" and if 0, you get "False value"... but over it all, so to speak, the logical test produces a #VALUE!
error if bith values are not numbers so you separate all the strings out with the IFERROR()
.