gpt4 book ai didi

excel - VBA "With"语句

转载 作者:行者123 更新时间:2023-12-04 20:48:43 24 4
gpt4 key购买 nike

我有多个变量要与“with”语句一起使用,而不是多个变量。有没有办法做到这一点?我有下面的片段,并想使用变量 a、b、c、d、e 和 f

       With a
.AutoFilter 1, "0"
With a
.clearContents
.ClearComments
End With
End With

最佳答案

而不是 a , b , c , d , ef定义一个数组并循环

Dim Vars(5) As Variant 'choose your type instead of Variant

'fill your variables with content
Vars(0) = a
Vars(1) = b
' …

Dim Var As Variant 'keep this Variant
For Each Var in Vars
With Var
.AutoFilter 1, "0"
With Var
.clearContents
.ClearComments
End With
End With
Next Var

关于excel - VBA "With"语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71799608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com