lpqs.net
当前位置:首页 >> vBA CAsE ElsE >>

vBA CAsE ElsE

Select Case range("A1") Case Is = "" Case Is = "a" MsgBox "Y" End Select 以上代码表示如果A1为空时不进行任何操作,A1=a时,提示"Y"

对 运行时,从第一个判断开始,按顺序向下读,当条件匹配时,执行条件匹配后面的语句,直到下一个ELSE 或 CASE 之前,然后就跳到 end if 或 end select 两个使用的方法一样,但条件较多时,select更简便,例: Select Case x Case 1 To 4, 7 To ...

Private Sub CB1_Click() Select Case Sheet1.Range("A1") Case "A" Sheet1.Range("A3") = "联想" Case "B" Sheet1.Range("A3") = "华硕" Case "C" Sheet1.Range("A3") = "惠普" Case "D" Sheet1.Range("A3") = "IBM" Case "E" Sheet1.Range("A3...

用for 语句+if语句可以实现 Sub dd() For myrow = 6 To 10 If Range("F" & myrow).Value 0 And Len(Trim(Range("E" & myrow).Value)) = 0 Then MsgBox "数据错误", , "E" & myrow End If Next End Sub

先说下你第一段代码:Dim iCounter As IntegerDim weekNames As StringFor iCounter = 1 To 5If iCounter = 1 ThenweekNames = "Monday"ElseIf iCounter = 2 ThenweekNames = "Tuesday"ElseIf iCounter = 3 ThenweekNames = "Wednesday"ElseIf i...

那就把a=2的条件放到Else里就行了,如 Case 1 If a = 1 Then '... ElseIf a = 2 Then '... End If Case 2 '... 这样的话,当IF条件满足时就不会执行ElseIf块中的语句了.

'1、Case Is > 0 And i = 100 And i = Int(100)-- 对于且逻辑 Case里没有这样的用法,你得用if..else 结构去做 '2、根据你的意思,如果用case的话,从0-100应该是 case 0 to 100 '3、另外你的 and Int(100) 是要表达什么意思

Private Sub CommandButton4_Click() Dim a(7, 14) As Single Dim i, j As Integer For i = 0 To 14 For j = 0 To 7 a(j, i) = Sheets("可行性").cells(102 + 2 * j, 4 + i).Value Select Case a(j, i) Case 1 To 3599 a(j, i) = 1 Case 3600 To...

Select 语句的基本语法结构是: Select Case [变量名] Case '情况1 '处理语句 Case '情况1 '处理语句 ........... Case '情况n '处理语句 Default '处理语句 End Select 其作用是根据给定的变量的不同的可能值做出相应的处理。当你的变量取值范...

excel的vba中也有select case语句. 如果你说的"语句"是指公式的话,choose,vlookup,index+match也许可以解决你的问题.

网站首页 | 网站地图
All rights reserved Powered by www.lpqs.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com