Excel - 如何以编程方式将“存储为文本的数字"转换为数字? [英] Excel - How do programmatically convert 'number stored as Text' to Number?
问题描述
我正在寻找一个简单的 Excel VBA 或公式,它可以将 Excel 中的整行从存储为文本的数字"转换为实际数字,以用于查找原因.
I'm looking for a simple Excel VBA or formula that can convert an entire row in Excel from 'number stored as Text' to an actual Number for vlookup reasons.
谁能指出我正确的方向?
Can anyone point me in the right direction?
推荐答案
更好的方法
您应该使用 INDEX(MATCH)
而不是 VLOOKUP
因为 VLOOKUP
以一种不可预测的方式运行,这会导致错误,例如您'大概正在经历.
Better Approach
You should use INDEX(MATCH)
instead of VLOOKUP
because VLOOKUP
behaves in an unpredictable manner which causes errors, such as the one you're presumably experiencing.
INDEX ( <return array> , MATCH ( <lookup value> , <lookup array> , 0) )
使用 0
作为 MATCH
的最后一个参数意味着匹配必须是精确的
这里是一些更深入的信息INDEX(MATCH)
-ing
Using 0
as the last argument to MATCH
means the match must be exact
Here is some more in-depth information on INDEX(MATCH)
-ing
添加零 +0
将值转换为数字.
这可以(危险地)使用 IFERROR()
扩展以将非数字文本变成零:
Add zero +0
to convert a value to a number.
This can be (dangerously) extended with IFERROR()
to turn non-numeric text into a zero:
=A2+0
=IFERROR(A2+0,0)
相反,您可以连接一个空字符串 &""
以强制该值是一个字符串.
For the inverse, you can catenate an empty string &""
to force the value to be a string.
如果 0
没有用作 MATCH
的最后一个参数,它会发现各种意外的匹配"……更糟糕的是,它可能会找到不同的值即使存在完全匹配.
If 0
is not used as the last argument to MATCH
, it will find all sorts of unexpected "matches" .. and worse, it may find a different value even when an exact match is present.
做一些额外的工作来确定MATCH
查找列中是否有重复通常是有意义的,否则将返回找到的第一个值(参见示例).
It often makes sense to do some extra work to determine if there are duplicates in the MATCH
lookup column, otherwise the first value found will be returned (see example).
MATCH
的帮助来自 这里,特别是第三个参数控制的匹配逻辑.
Help with MATCH
comes from here, notably the matching logic the 3rd argument controls.
这篇关于Excel - 如何以编程方式将“存储为文本的数字"转换为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!