我被困在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