|
楼主 |
发表于 2015-8-1 21:04
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
不比不知道,
原来直接用工作表函数=offset(,match(,,)-1,match(,,)-1,,)
分段计算更快得多。
Sub 整理()
ActiveWindow.ActivateNext
nn = ActiveWorkbook.Name
gg = Sheets.Count
ActiveWindow.ActivateNext
tt = Timer
Sheets(i).Select
cc = Cells(1, Columns.Count).End(xlToLeft).Column
For j = 1 To 32
[a1] = "[" & nn & "]" & Workbooks(nn).Sheets(j).Name & "!"
Cells(1, cc + j) = Workbooks(nn).Sheets(j).Name
For k = 1 To 8
g0 = Application.RoundDown([a2] / 8, 0)
g = (k - 1) * g0 + 10
[a6] = [a1].Offset(g, 0)
[a7] = [a1].Offset(g + g0 - 1, 0)
[a8].FormulaR1C1 = "=SUBSTITUTE(ADDRESS(1,MIN(MATCH(r6c,INDIRECT(r1c1&""1:1""),0)),4),1,)"
[a9].FormulaR1C1 = "=SUBSTITUTE(ADDRESS(1,MIN(MATCH(r7c,INDIRECT(r1c1&""1:1""),0)),4),1,)"
Range("a8:a9").Copy: Selection.PasteSpecial 3
Cells(10, cc + j).Select
ActiveCell.FormulaR1C1 = _
"=OFFSET(INDIRECT(R1C1&""A1""),MATCH(RC2,INDIRECT(R1C1&""B:B""),)-1,MATCH(RC1,INDIRECT(R1C1&""1:1""),)-1,,)"
Selection.Copy: Range(Cells(g, cc + j), Cells(g + g0 - 1, cc + j)).PasteSpecial 2: Selection.Copy: Selection.PasteSpecial 3
Selection.Replace What:="#*", Replacement:="0"
Next
[a3] = Timer - tt
Next
End Sub |
|