从2017年到2066年,我有一张50年的工作表。这个宏为头10年制作了一个打印区域,第十年是用户输入并隐藏任何其他列。如果用户输入大于2026年,我们将删除连续第10年(2026年),并将其替换为用户输入。
我发现我的宏非常慢,我正在寻找关于如何加速它的反馈。
With Sheet1
If userinputyear > 2026 Then
c = 10 'column index corresponding to consecutive 10th year 2026
Do While .Cells(5, c) <> userinputyear
.Cells(5, c).EntireColumn.Hidden = True
c = c + 1
Loop
Do While c + 1 <> 50 'column index corresponding to year 2066
.Cells(5, c + 1).EntireColumn.Hidden = True
c = c + 1
Loop
end with 发布于 2017-03-24 23:22:00
这会更快吗?(假设您的列是根据年份排序的)
With Sheet1
If userInputYear > 2026 Then
.Cells(1, 10).Resize(, 41).EntireColumn.Hidden = True
.Columns(userInputYear - 2016).Hidden = False
End If
End Withhttps://stackoverflow.com/questions/43010165
复制相似问题