Msgbox的Excel VBA IF语句(range1 <> range2 + range3)然后

时间:2019-03-27 12:03:09

标签: excel vba compare msgbox

VBA菜鸟在这里

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

def remap(data):
    return b''.join(lookup[byte] for byte in data)

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

这是我的代码:

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

1 个答案:

答案 0 :(得分:0)

就这样:

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

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