看板 Visual_Basic 關於我們 聯絡資訊
※ 引述《lytn (sapphira)》之銘言: : 想問一下 : For i = x to y : A(i) : B(i) : C(i) : next : 以上結構,如果是需要ABC都跑完是OK的 : 如果是有時候只要跑到A 或 B 即完成,有沒有預設的指定可以做到? : 我以前是用巢狀IF一層一層去包,但是又很煩 : 有沒有其他作法可以分享呢? 是要跳下一個i還是要跳出迴圈?? 如果是要跳出迴圈,那用Exit For 如果是要跳下一個i,在Excel VBA只能用GoTo 例如 For i = x to y if A(i)=m then GoTo Continue1 elseif A(i) =n then Exit For end if if B(i)=m then GoTo Continue1 elseif B(i) =n then Exit For end if if C(i)=m then GoTo Continue1 elseif C(i) =n then Exit For end if Continue1: Next -- I am a phantom. I existed on people's need. When nobody needs me anymore, I would disappear. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 175.180.135.78
Marty:原PO似乎是要問除了用if去包以外的方法...不過應該是很難.. 12/16 08:08
MOONRAKER:我覺得他是需要相當於C的continue的東東。在VBA的確是只 12/16 11:02
MOONRAKER:能用goto或用if包住,即使do...loop也只能這樣弄。 12/16 11:04
lytn:感謝詳細說明 12/17 14:24