Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在IF语句的THEN分支中使用AND_Vba_Excel - Fatal编程技术网

Vba 在IF语句的THEN分支中使用AND

Vba 在IF语句的THEN分支中使用AND,vba,excel,Vba,Excel,VBA是否允许在IF语句的THEN分支中使用AND语句 If cel.Offset(0, 6).Value = "HardToken" Then wshT.Cells(r, 14).Value = "Physical" And wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value 如果没有-那么如何重新构造上述内容?您应该使用If..then..EndIf: If cel.Offset(0, 6).Value = "HardToken" Then

VBA是否允许在IF语句的THEN分支中使用AND语句

If cel.Offset(0, 6).Value = "HardToken" Then wshT.Cells(r, 14).Value = "Physical" And wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value

如果没有-那么如何重新构造上述内容?

您应该使用
If..then..EndIf

If cel.Offset(0, 6).Value = "HardToken" Then 
   wshT.Cells(r, 14).Value = "Physical"
   wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value
End if

您应该使用
If..Then..EndIf

If cel.Offset(0, 6).Value = "HardToken" Then 
   wshT.Cells(r, 14).Value = "Physical"
   wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value
End if

您应该使用
If..Then..EndIf

If cel.Offset(0, 6).Value = "HardToken" Then 
   wshT.Cells(r, 14).Value = "Physical"
   wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value
End if

您应该使用
If..Then..EndIf

If cel.Offset(0, 6).Value = "HardToken" Then 
   wshT.Cells(r, 14).Value = "Physical"
   wshT.Cells(r, 19).Value = cel.Offset(0, -2).Value
End if

和是一个布尔运算符,用于确定是否满足条件。它只在IF()语句的条件部分使用,而不会在“Then”分支中向语句添加更多命令

在伪代码中:

If CellA1 equals "blue" AND CellB1 equals "green" then
   msgbox("A1 is blue")
   msgbox("B1 is green")
end if
不能使用和向代码中添加其他语句。你不需要。在上面的代码示例中,两个消息框将依次出现。但前提是这两个条件都满足。这两个条件用AND运算符连接,因此只有当两个条件都为真时,消息框才会出现

从您的示例代码来看,如果一个条件为真,您似乎只想执行多个操作。你根本不需要这个和在那里

If something = somethingElse then
   do this
   do that
   do the other
end if

没有,而且是必需的

和是一个布尔运算符,用于确定是否满足条件。它只在IF()语句的条件部分使用,而不会在“Then”分支中向语句添加更多命令

在伪代码中:

If CellA1 equals "blue" AND CellB1 equals "green" then
   msgbox("A1 is blue")
   msgbox("B1 is green")
end if
不能使用和向代码中添加其他语句。你不需要。在上面的代码示例中,两个消息框将依次出现。但前提是这两个条件都满足。这两个条件用AND运算符连接,因此只有当两个条件都为真时,消息框才会出现

从您的示例代码来看,如果一个条件为真,您似乎只想执行多个操作。你根本不需要这个和在那里

If something = somethingElse then
   do this
   do that
   do the other
end if

没有,而且是必需的

和是一个布尔运算符,用于确定是否满足条件。它只在IF()语句的条件部分使用,而不会在“Then”分支中向语句添加更多命令

在伪代码中:

If CellA1 equals "blue" AND CellB1 equals "green" then
   msgbox("A1 is blue")
   msgbox("B1 is green")
end if
不能使用和向代码中添加其他语句。你不需要。在上面的代码示例中,两个消息框将依次出现。但前提是这两个条件都满足。这两个条件用AND运算符连接,因此只有当两个条件都为真时,消息框才会出现

从您的示例代码来看,如果一个条件为真,您似乎只想执行多个操作。你根本不需要这个和在那里

If something = somethingElse then
   do this
   do that
   do the other
end if

没有,而且是必需的

和是一个布尔运算符,用于确定是否满足条件。它只在IF()语句的条件部分使用,而不会在“Then”分支中向语句添加更多命令

在伪代码中:

If CellA1 equals "blue" AND CellB1 equals "green" then
   msgbox("A1 is blue")
   msgbox("B1 is green")
end if
不能使用和向代码中添加其他语句。你不需要。在上面的代码示例中,两个消息框将依次出现。但前提是这两个条件都满足。这两个条件用AND运算符连接,因此只有当两个条件都为真时,消息框才会出现

从您的示例代码来看,如果一个条件为真,您似乎只想执行多个操作。你根本不需要这个和在那里

If something = somethingElse then
   do this
   do that
   do the other
end if
没有,而且是必需的