excel vba“是数字的”验证多个文本框 [英] excel vba "is numeric" validation for multiple text boxes

查看:202
本文介绍了excel vba“是数字的”验证多个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的excel VBA表格上有超过100个文本框和

我请求帮助我如何写数字

验证所有框一起没有

为每个/每个文本框写。谢谢

解决方案



我假设您默认保留了100个文本框(名称)。如果是这样,您可以通过编写如下所述的简单VBA宏代码来实现此目的。如果该值不是数字,则弹出文本框的名称。你可以改变适合你的功能。

 私人  Sub  CheckIsNumeric()
Dim i As 整数
Dim 标志 As Boolean
对于 i = 1 To 100
flag = IsNumeric(Controls( TextBox& i).Text)
如果 flag = False 然后
MsgBox( TextBox& i& 不是数字
退出 对于
结束 如果
下一步
结束 Sub



希望我正确理解你的问题。根据文本框计数更改值100。



谢谢

Sriram.B


我非常感激,但只是想知道究竟放在哪里码。我只是一个初学者,所以我要求更多详细说明。感谢

I have over 100 text boxes on my excel VBA form and
I request for help on how i can write "is numeric"
validation for all the boxes together without having
to write for every/each text box. thanks

解决方案

Hi,
I assume you left thos 100 Textbox(s) (Name) default. If so you can acheive this by writing a simple VBA macro code like mentioned below. If the value is not numeric this pops the name of the textbox. you can change the funcionality which suits for you.

Private Sub CheckIsNumeric()
Dim i As Integer
Dim flag As Boolean
For i = 1 To 100
   flag = IsNumeric(Controls("TextBox" & i).Text)
   If flag = False Then
       MsgBox ("TextBox" & i & " is not numeric")
   Exit For
   End If
Next
End Sub


Hope I understood your question correctly. Change the value 100 based on your textbox count.

Thanks
Sriram.B


Im very grateful but just wondering where exactly to place the code. Im just a beginner so Im requesting for more elaborations please. thanks


这篇关于excel vba“是数字的”验证多个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆