if判断有三种格式
Sub Test() Dim the_value the_value = ThisWorkbook.Sheets("Sheet1").Range("A1").Value End Sub
1.if...endif
With ThisWorkbook.Sheets("Sheet1") If the_value = "1" Then MsgBox (the_value) End If End With
2.if...else...endif
With ThisWorkbook.Sheets("Sheet1") If the_value = "1" Then MsgBox (the_value) Else MsgBox (the_value) End If End With
3.'if...elseif...else
With ThisWorkbook.Sheets("Sheet1") If the_value = "1" Then MsgBox (the_value) ElseIf the_value = "2" Then MsgBox (the_value) ElseIf the_value = "3" Then MsgBox (the_value) Else MsgBox (the_value) End If End With
标签:语句,...,vba,End,Sheets,流程,value,ThisWorkbook,MsgBox From: https://www.cnblogs.com/shizunatsu/p/17183879.html