gpt4 book ai didi

vba - 添加组合框项目

转载 作者:行者123 更新时间:2023-12-03 00:09:16 26 4
gpt4 key购买 nike

有没有办法缩短这个VBA:

Me.cboDeptU1.AddItem "1"
Me.cboDeptU1.AddItem "2"
Me.cboDeptU1.AddItem "3"
Me.cboDeptU1.AddItem "4"
Me.cboDeptU1.AddItem "5"

Me.cboDeptU.SetFocus

我在同一个子目录中也有这个:

Me.cboDeptL1.AddItem "1"
Me.cboDeptL1.AddItem "2"
Me.cboDeptL1.AddItem "3"
Me.cboDeptL1.AddItem "4"
Me.cboDeptL1.AddItem "5"

Me.cboDeptL.SetFocus

最佳答案

替换

Me.cboDeptU1.AddItem "1"
Me.cboDeptU1.AddItem "2"
Me.cboDeptU1.AddItem "3"
Me.cboDeptU1.AddItem "4"
Me.cboDeptU1.AddItem "5"

For i = 1 to 5
Me.cboDeptU1.AddItem Cstr(i)
Next i

关于vba - 添加组合框项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42100074/

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