楼主: lam_fukming
1170 1

[问答] How to stop VBA code processing??? [推广有奖]

  • 3关注
  • 9粉丝

已卖:1921份资源

博士生

20%

还不是VIP/贵宾

-

威望
0
论坛币
6005 个
通用积分
12.2090
学术水平
43 点
热心指数
43 点
信用等级
40 点
经验
94521 点
帖子
324
精华
0
在线时间
25 小时
注册时间
2011-8-29
最后登录
2025-5-7

楼主
lam_fukming 发表于 2013-12-30 22:30:32 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
From the following code, since it will create multiple layers of Sub. When I try "Exit Sub", it just exit the current Sub layer, but return to the previous Sub layer. So, my question is how to exit the code ENTIRELY when a condition "BCDEA" is met?


Actually, I know that I can run the entire code first, then search "BCDEA" in the worksheet, and manually delete the rest. However, it may lead to a huge computational cost which discourages me to do so.


Sub ABCDE()
Dim x, y As Variant
    y = "ABCDE"
    x = ""
Call GetPermutation(x, y)
End Sub

Sub GetPermutation(ByVal x, ByVal y)
Dim i, j, CurrentRow As Integer
CurrentRow = Application.WorksheetFunction.CountA(Columns(1))
    j = Len(y)
    If j < 2 Then
        Cells(CurrentRow + 1, 1) = x & y

       If Cells(CurrentRow + 1, 1) = "BCDEA" then Exit Sub     
    Else
        For i = 1 To j
            Call GetPermutation(x + Mid(y, i, 1), Left(y, i - 1) + Right(y, j - i))
        Next
    End If
End Sub


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Processing processI Process ROCE code following multiple previous question current

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
wocacawo + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

大道無門,
千差有路,
透得此關,
乾坤獨步﹗

沙发
TimeT 发表于 2014-1-1 20:32:24
只需要把 "Exit Sub" 改成 "End"。我试过,这样就可以遇到BCDEA就停下来。
已有 1 人评分论坛币 收起 理由
星野 + 50 热心帮助其他会员

总评分: 论坛币 + 50   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 05:12