特定消息框未显示

特定消息框未显示

我试图一次输出几个消息框,我确实这样做了。但是当我尝试只输出其中一个时,什么也没发生:我将只显示那些不起作用的消息框。如果单元格值为整数且不在 6 到 72 之间,我只想显示这些消息框:

5.字体大小必须是 6 到 72 之间的整数

6.段落间距必须是 6 到 72 之间的整数

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   Dim cell As Range
   Dim cell2 As Range
   Dim i As Integer
   Dim cellVal As Integer
   Dim cellVal2 As Integer
   Dim sCellVal As String
   Dim a As Variant     
   Dim rngcheck As Range
   Dim rngcheck2 As Range
   sCellVal = Range("A2").Value
   cellVal = Range("B3").Value
   cellVal2 = Range("B4").Value

    If Not cellVal = (6 < 72) Then
         Cancel = True
         mess = mess & vbCrLf & "Font Size must be an integer from 6 till 72"
    End If

    If Not cellVal2 = (6 < 72) Then
         Cancel = True
         mess = mess & vbCrLf & "Paragraph Spacing Before must be an integer from 6 till 72"
    End If

    If mess <> "" Then MsgBox mess

End Sub

答案1

您需要更改此行:

If Not cellVal = (6 < 72) Then

If cellVal < 6 Or cellVal > 72 Then

对 执行相同操作cellVal2

相关内容