修复IsNumeric Loop Bug?

时间:2015-06-04 17:01:38

标签: excel vba loops isnumeric

我正在尝试修复一个简单的循环,以便在用户输入整数之前消息框不会消失。 这是我的代码:

Sub PlateMicro()

strName = InputBox(Prompt:="Enter number of wells in plate. The default is 96 (8X12).", _
      Title:="PLATE SETUP", Default:="96")

Dim wellCount As Object
Dim numericCheck As Boolean
numericCheck = IsNumeric(wellCount)

If IsNumeric(wellCount) Then
Range("A1").Value = wellCount 'Enter the number of plate wells selected into template.
Else: strName = InputBox(Prompt:="You must enter an integer. Enter number of wells in plate. The default is 96 (8X12)." _
      , Title:="PLATE SETUP", Default:=userDefaultChoice)
End If
End Sub

1 个答案:

答案 0 :(得分:0)

考虑:

Sub intCHECK()
   Dim var As Variant
   var = "whatever"
   While Not IsNumeric(var)
      var = Application.InputBox(Prompt:="Enter integer", Type:=2)
   Wend

   MsgBox "Thanks!"
End Sub

如果您触摸取消

,这将允许您退出
相关问题