【问题标题】:Excel VBA IF statement for Msgbox (range1<>range2+range3) then用于 Msgbox 的 Excel VBA IF 语句 (range1<>range2+range3) 然后
【发布时间】:2019-03-27 12:03:09
【问题描述】:

这里是 VBA 菜鸟,

所以我有 3 列(A、B 和 C)

A = Received Goods
B = Sent Goods for Shop 1
C = Sent Goods for Shop 2

我想要 B+C = A 中的值单元格,否则给我一条错误消息。

这是我的代码:

If Range("A1").End(xlDown).Value <> Range("B1").End(xlDown).Value & Range("C1").End(xlDown).Value Then
MsgBox "Error, wrong number of sent goods"
End If

End Sub

【问题讨论】:

    标签: excel vba compare msgbox


    【解决方案1】:

    就是这样:

    Option Explicit
    Sub Warning()
    
        Dim A As Long, B As Long, C As Long 'in case you have floating numbers use Single or Double instead
    
        With ThisWorkbook.Sheets("NameOfYourSheet")
            A = .Cells(.Rows.Count, "A").End(xlUp)
            B = .Cells(.Rows.Count, "B").End(xlUp)
            C = .Cells(.Rows.Count, "C").End(xlUp)
        End With
    
        If B + C <> A Then
            MsgBox "Error, wrong number of sent goods"
        End If
    
    End Sub
    

    我假设您正在尝试每一列的最后一行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-28
      • 2020-07-18
      • 2021-09-10
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多