|
我在一张工作簿中,sheet1建目录时,第一次建立时,速度慢。有时要十几秒。工作簿中有几百个工作表,现在模拟了几个。但还是慢。 不知道怎么改善。也不知什么地方降低了速度。哪位大佬能否指点一下?代码如下:
Sub BuildSheetList() tt = Timer Application.ScreenUpdating = False Application.EnableEvents = False Dim i%, k&, a&, s&, strName As String Sheet1.Select With Range("a:f") .ClearContents .NumberFormat = "@" End With Range("a1") = " 总 目 录" Range("a2,e2") = "物料 号" Range("b2,f2") = "价 格" For i = 2 To Sheets.Count - 1 s = Int(i / 2) + 2 a = (i Mod 2) * 4 + 1 k = a + 1 strName = Sheets(i).Name Cells(s, a).Value = strName Cells(s, k).Value = Sheets(i).Cells(4, 12).Value ActiveSheet.Hyperlinks.Add anchor:=Cells(s, a), Address:="", _ SubAddress:="'" & strName & "'!g4", TextToDisplay:=strName Next 'On Error Resume Next With Range("a:a,e:e").Font .Name = "楷体" .FontStyle = "常规" .Size = 16 .Color = vbRed End With On Error Resume Next With Range("b:b,f:f").Font .Name = "楷体" .FontStyle = "常规" .Size = 10 .ThemeColor = xlThemeColorAccent3 End With Application.EnableEvents = True Application.ScreenUpdating = Truett2 = Timer - ttDebug.Print tt2End Sub
|
|