下面是我的代码:
Dim m As String, n As Long
n = InputBox("Enter sales amount: ")
If n < 500 Or n > 5000 Then
ActiveCell.Value = n
ActiveCell.Interior.Color = RGB(255, 0, 0)
m = InputBox("Reason why increase/decrease? ")
ActiveCell.Offset(0, 1).Value = m
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Value = n
ActiveCell.Offset(1, 0).Select
End If
我正在弄清楚如果输入是字符串,那么输入框将提示并要求整数,如何验证值?
预先感谢您的回答。
Code:
Dim m As String, n As String, sales as long
TryAgain:
n = InputBox("Enter sales amount: ")
If Not IsNumeric(n) Then
MsgBox "Entry should be a number!"
GoTo TryAgain
End If
sales = CLng(n)
If sales < 500 Or sales > 5000 Then
ActiveCell.Value = sales
ActiveCell.Interior.Color = RGB(255, 0, 0)
m = InputBox("Reason why increase/decrease? ")
ActiveCell.Offset(0, 1).Value = m
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Value = sales
ActiveCell.Offset(1, 0).Select
End If
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)