我被困在VBA中。我在网站上尝试了其他解决方案,但仍然无法正确使用。我使用多个模块和表单来获取一些信息输入到Excel的单元格中。但是,当msgBox留空时,它给我一个13型不匹配的错误。我试过isNull,但不完全理解如何使用它。Excel VBA运行时错误13 - 盒子空白时不匹配
任何帮助将不胜感激,请保持尽可能简单的答案,因为我是一个新手程序员充其量。由于
Sub GetEndCostGateFees()
Dim qtyGateFees As Double
Dim msg As String
Const MinCost As Integer = 0
Const MaxCost As Integer = 200
msg = "Please enter the cost, per tonne, of Gate fees "
Do
qtyGateFees = InputBox(msg, "Gate Fees")
If IsNull(qtyGateFees) Then
MsgBox ("Please enter a value. Enter 0 if none")
End If
If IsNumeric(qtyGateFees) Then
If qtyGateFess >= MinCost And qtyGateFees <= MaxCost Then Exit Do
End If
msg = "Please enter a valid number"
msg = msg & vbNewLine
msg = msg & "Please enter number between " & MinCost & " and " & MaxCost
Loop
Sheet25.Range("B43").Value = qtyGateFees
末次
将'Option Explicit'添加到模块的开头。这会使问题变得明显。 – RBarryYoung
你在哪一行得到错误? – ARich