gpt4 book ai didi

excel - 宏 if, then... 找不到错误

转载 作者:行者123 更新时间:2023-12-04 21:02:46 27 4
gpt4 key购买 nike

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

Sub Comhouse()
If Worksheets("(2.2) TRA worksheet").Range("AU425").Value > Worksheets("(2.0) Hotel Inventory").Range("S421").Value 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
End Sub

最佳答案

检查数值:

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

关于excel - 宏 if, then... 找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32974280/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com