簡體   English   中英

帶有 Select Case 的 Excel VBA 運行時錯誤 13

[英]Excel VBA run time error 13 with Select Case

我有一些嵌套的Select Case代碼,當我選擇主案例 2、3、4 或 5 時,它可以工作(我得到每個案例的嵌套案例選項),但是當我選擇Case 1我得到一個運行時錯誤 13,它忽略了輸入框定義選項。

我已經看了一百遍,但看不到我的錯誤在哪里,某處必須有一個,想知道是否有人可以看到這里缺少什么或錯誤,這是我的代碼中引發錯誤的部分。


Variants:

Sizes = Application.InputBox("Which EMS 066 option do you wish to load & check against" & vbLf & vbLf & vbLf & "1. S690 All variants & sizes" & vbLf & vbLf & "2. S890 All variants & sizes" & vbLf & vbLf & "3. S960 All variants & sizes" & vbLf & vbLf & "4. S650MC-D All sizes" & vbLf & vbLf & "5. S700MC-D All sizes" & vbLf & vbLf & vbLf, "Select which option to load")

If Sizes = False Then
    Exit Sub
Else
    Select Case Sizes
        Case 1
            ws.Activate
            Ans = MsgBox("You have selected S690 variant?", vbYesNo) ' allows a loop if you have made a mistake and will take you back to the selection option
            If Ans = vbNo Then GoTo Variants Else
                Option1 = Application.InputBox("Please define the specific type and size of S690 you require to check against" & vbLf & vbLf & "1. S690Q 3mm to 50mm" & vbLf & "2. S690Q 50 to 100mm" & vbLf & "3. S690Q100 to 150mm" & vbLf & vbLf & "4. S690QL 3 to 50mm" & vbLf & vbLf & "5. S690QL 50 to 100mm" & vbLf & vbLf & "6. S690QL 100 to 150mm" & vbLf & vbLf & "7. S690QL1 3 to 50mm" & vbLf & vbLf & "8. S690QL1 50 to 100mm" & vbLf & vbLf & "9. S690QL1 100 to 150mm" & vbLf & vbLf, "Plese select the Option from the Drawing")

                Select Case Option1
                    Case 1
                        Ans = MsgBox("You have selected S690Q between 3 and 50mm is this correct?", vbYesNo) ' allows a loop if you have made a mistake and will take you back to the selection option
                        If Ans = vbNo Then GoTo Variants Else:
                            rng2.Copy: rng1.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
                              :=False, Transpose:=False
                            rng4.Copy: rng3.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
                              :=False, Transpose:=False
                            rng6.Copy: rng5.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                              :=False, Transpose:=False

這讓我一整天都發瘋了,我一生都看不到哪里出了問題,我什至從第二個主要Case Select復制了代碼,並嘗試了未經編輯和編輯的代碼,但我得到了同樣的錯誤。

輸入框的提示最多可以有 255 個字符。 如果它有更多,你會得到錯誤 2015。如果你來到你的第二個Select Case ,你將錯誤與1進行比較並得到錯誤 13。

所以:在情況 1 中縮短你的提示,你很好:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM