小编Al.*_*Sal的帖子

对于Excel VBA中的每个类属性

我有一些看起来像这样的代码:

pos.Clutch = sh2.Cells(R, Clutch)
pos.Wiper = sh2.Cells(R, Wiper)
pos.Alternator = sh2.Cells(R, Alternator)
pos.Compressor = sh2.Cells(R, Compressor)
...
pos.Telephone = sh2.Cells(R, Telephone)
poss.Add pos
Run Code Online (Sandbox Code Playgroud)

poss是一个集合,Clutch,Wiper等是列索引(从1开始).这目前有效,但非常难看.我正在寻找一种方法来做这样的事......

Do While i <= classProperty.count
    For each classProperty in pos
        classProperty = sh2.Cells(R + 1, i)
    Next classProperty
Loop
Run Code Online (Sandbox Code Playgroud)

显然这不起作用,但是有没有人对如何在类中完成大致相同的方法或集合有任何建议?

excel vba for-loop class

5
推荐指数
1
解决办法
5047
查看次数

标签 统计

class ×1

excel ×1

for-loop ×1

vba ×1