小编dmi*_*hel的帖子

循环内的VBA偏移 - 永远运行

我对编程很陌生,我觉得VBA对我来说是个好地方,因为我在Excel上做了很多工作.

我创建了一个宏,它从输入框中取一个整数(我一直在使用2,3和4来测试),它创建了一个这个数字的4层层次结构的集合; 例如输入"2"会产生

1.0.0.0
1.0.0.1
1.0.0.2
1.0.1.0
1.0.1.1
1.0.1.2 etc.
Run Code Online (Sandbox Code Playgroud)

我让宏按预期工作,但它需要永远运行.我认为循环中的偏移会减慢它的速度.有没有人有任何建议来加快这个速度?任何一般反馈也是受欢迎的.

Sub Tiers()

'Input Box
Dim Square As Integer
Square = InputBox("Enter Number of Tiers")
Range("f5").Select
Selection.Value = 0
 With Application
    .ScreenUpdating = False
End With

'Rows down
Dim g As Integer
Dim h As Integer
Dim i As Integer
Dim j As Integer

'Start For loops
For g = 1 To Square
    For h = 0 To Square
        For i = 0 To Square
            For j = 0 To …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

2
推荐指数
1
解决办法
82
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1