excel中仅验证字符串值的公式
我希望用户只在 Excel 单元格中输入字符。 我在Excel的自定义公式中使用了ISTEXT(value),但无法获得像hgdashj2132154这样的字符串的正确输出,请帮忙... 感谢你..
I want user to enter only characters in excel cell..
i used ISTEXT(value) in custom formula of excel but can't get correct output for string like hgdashj2132154 please help...
thank u..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需要一点正则表达式魔法即可。您需要一个用户定义的函数和正则表达式插件。在“开发人员”视图中,转到“工具”|“参考”并勾选“Microsoft VBScript 正则表达式 5.5”。
这是函数:
结果:
如果您不想使用正则表达式,那么总是有“Like Loop”:
It just takes a little regular expression magic. You need a user-defined function and the regular expression add-in. In the Developer view go to Tools|References and tick Microsoft VBScript Regular Expressions 5.5.
Here's the function:
The results:
If you'd rather do without regular expressions, there's always the "Like Loop":
哎呀,我在我的书签网站上找到了这个。它本质上与 Marc Thibault 的建议相同,但不需要任何额外的参考:
http: //www.techonthenet.com/excel/formulas/alphanumeric.php
Smack, I found this on my bookmarked sites. It's essentially the same concept as Marc Thibault's suggestion, but doesn't require any additional references:
http://www.techonthenet.com/excel/formulas/alphanumeric.php
纯 VBA 方法:(
我编辑了答案以使用 Like 运算符而不是 IsNumeric 函数。现在只有字符 a 到 z 被视为有效,而不仅仅是非数字字符。)
A pure VBA approach:
(I edited my answer to use the Like operator instead of the IsNumeric function. Now ONLY characters a to z are considered valid, instead of just non-numeric characters.)