首页 > 解决方案 > 结束块 VBA 消息

问题描述

下面是我写的代码。我不明白为什么我不断收到错误消息“如果没有阻止则结束”....有什么建议吗?

Sub SaveTemplate()
Dim TempRow As Long, TempCol As Long
With Sheet1
    If .Range("E3").Value = Empty Or .Range("G3").Value = Empty Or .Range("E5").Value = Empty Then MsgBox "Please contact us with questions"
    Exit Sub
End If
If .Range("B3").Value = True Then 'New Template
        TempRow = .Range("D999").End(xlUp).Row + 1 'First Avail Row
Else
    TempRow = .Range("B4").Value
End If
    For TempCol = 4 To 8
        .Cells(TempRow, TempCol).Value = .Range(.Cells(15, TempCol).Value).Value 'Bring down values from form into table
    Next TempCol
    .Range(TempRow & "." & TempRow).WrapText = False
End With
    
End Sub

标签: excelvba

解决方案


在新行上写下: MsgBox "Please contact us with questions"

它的编写方式,它不需要End If.


推荐阅读