宏,如果,那么......没有找到错误

时间:2015-10-06 15:49:41

标签: excel-vba vba excel

下面的宏有什么问题?我只想评估一个选项卡中的一个单元格是否大于另一个选项卡中的另一个单元格。然后是MsgBox:

"D"

1 个答案:

答案 0 :(得分:0)

检查数值:

Sub Comhouse()
   Dim v1 As Variant, v2 As Variant
   v1 = Worksheets("(2.2) TRA worksheet").Range("AU425").Value
   v2 = Worksheets("(2.0) Hotel Inventory").Range("S421").Value
   If IsNumeric(v1) And IsNumeric(v2) Then
      If v1 > v2 Then
         MsgBox ("Please check inventory imputed in Com and House for every day as it may be exiding the total inventory available")
         Exit Sub
      Else
         MsgBox ("All correct")
      End If
   Else
      MsgBox "non-numeric values"
   End If
End Sub