作者:乔山办公网日期:
返回目录:excel表格制作
函数中的if语句zhidao=if(条件,符合条件结果,不符合条件结果)。
VBA中也有一个同样的函数,为了跟函数的if区分,vba中的名称为iif,使用回方法与函数完全一致,iif(条件,符合条件结果,不符合条件结果)。
VBA中另答外一种if表达方式更为常用,格式为
if 条件 then 执行结果
或者
if 条件 then
结果一
结果二
else if 条件
结果
end if
4. VBA中的if语句常用来与for..next循环搭配使用,亦可用do while...Loop语句代替。
show 之前 加个 if 判断
if UserForm4.textbox2.text= UserForm4.textbox3.text then UserForm5.show
if cells(6,2)百=1 then
cells(7,3)=cells(7,8)
elseif cells(6,2)=2 then
cells(7,3)=cells(8,8)
elseif cells(6,2)=3 then
cells(7,3)=cells(9,8)
endif
注意度 cells(i,问j) i表示第答多少行,j表示第多少列专
比如c7 表示的是属第7行,第3列的单元