[英]Logical Operators in Excel: If Not
I'm new in Excel VBA programming and I am trying to do the following within a Macro: 我是Excel VBA编程的新手,我正在尝试在宏中执行以下操作:
If Not Sheets(Currencies).Range("B2") <> "USD" Then
Sheets(Currencies).Range("B2").Value = "=USD"
Call Sheet3.UpdateCurrencyList
End If
EDIT: I have fixed the codes from the comments below, but now I get runtime 9 error. 编辑:我已经从下面的注释中修复了代码,但是现在我得到运行时9错误。
There are 2 errors: 有两个错误:
Try this: 尝试这个:
Sub MySub()
If Not Sheets("Currencies").Range("B2") = "USD" Then
Sheets("Currencies").Range("B3").Value = "USD"
Call Sheet3.UpdateCurrencyList
Else
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.