vba满足第一个条件再判断第二个条件,如果第一个不成立则结束。比如if (第一个条件)
成立,再判断第二个
不成立,结束
vba满足第一个条件再判断第二个条件,如果第一个不成立则结束。
答案:2 悬赏:50
解决时间 2021-04-22 18:09
- 提问者网友:清羽墨安
- 2021-04-21 22:39
最佳答案
- 二级知识专家网友:时光不老我们不分离
- 2021-04-21 22:57
if 条件一 then
elseif 条件二 then
end if
这样?
elseif 条件二 then
end if
这样?
全部回答
- 1楼网友:眠于流年
- 2021-04-22 00:04
option explicit
public sub ifind(rng as range)
dim dic, arr, arra(), arrb(), arrd(), i&, tmp
set dic = createobject("scripting.dictionary")
dic.add "城市1", "区号1,省份1,邮编1"
dic.add "城市2", "区号2,省份2,邮编2"
dic.add "城市3", "区号3,省份3,邮编3"
dic.add "城市4", "区号4,省份4,邮编4"
dic.add "城市5", "区号5,省份5,邮编5"
dic.add "城市6", "区号6,省份6,邮编6"
dic.add "城市7", "区号7,省份7,邮编7"
dic.add "城市8", "区号8,省份8,邮编8"
dic.add "城市9", "区号9,省份9,邮编9"
dic.add "城市10", "区号10,省份10,邮编10"
'…………自己添加……
with rng
tmp = .rows.count
redim arra(1 to tmp), arrb(1 to tmp), arrd(1 to tmp)
arr = .columns(1).cells
for i = 1 to ubound(arr)
tmp = cstr(arr(i, 1))
if dic.exists(tmp) then
tmp = split(dic(tmp), ",")
arra(i) = tmp(0)
arrb(i) = tmp(1)
arrd(i) = tmp(2)
end if
next
.columns(-1) = application.worksheetfunction.transpose(arra)
.columns(0) = application.worksheetfunction.transpose(arrb)
.columns(2) = application.worksheetfunction.transpose(arrd)
end with
end sub
private sub commandbutton1_click()
dim rng as range
with activesheet
set rng = application.intersect(selection.cells, .range("c2:c65536"), .usedrange)
if not rng is nothing then
call ifind(rng)
end if
end with
end sub
-----------------
自己建立个按钮,
运行前选中c列中要更新的数据,点按钮执行
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯