Public Sub 合并计算() | Dim arr(1 To 2) As String | Dim i As Integer, rng As Range | For i = 1 To 2 | arr(i) = Worksheets(i).Range("A1").CurrentRegion.Address(True, True, ReferenceStyle:=xlR1C1, external:=True) | Next i | Worksheets("总汇").Range("A1").Consolidate sources:=arr, Function:=xlSum, toprow:=True, leftcolumn:=True | Worksheets("总汇").Range("A1").Value = "机构" | Sheets(1).Range("A1").Copy | With rng | .Resize(1, CurrentRegion.Columns.Count).PasteSpecial xlPasteFormats | End With | Sheets(1).Range("A2").Copy | With rng.CurrentRegion.Offset(1, 0) | .Resize(.Rows.Count - 1, .Columns.Count).PasteSpecial xlPasteFormats | End With | Application.CutCopyMode = False | rng.Select | Set rng = Nothing | End Sub |
这是第70个技巧99页的例题,可是我怎么也做不对呢?提示“下标月界”。请高手指教!!!
|