Sub 汇总() Dim i, arr arr = Worksheets("数据").[A1:B21] With Worksheets("输出") For i = 1 To UBound(arr) .Cells(i + 1, 1) = arr(i, 1) + arr(i, 2) '在“输出”工作表的A列进行求和 .Cells(i + 1, 2) = arr(i, 1) & arr(i, 2) '在“输出”工作表的B列进行合并 Next i End With End Sub
Sub strMerge() Dim i As Integer Dim str As String Worksheets("数据").Activate For i = 1 To Range("A1").CurrentRegion.Rows.Count str = Worksheets("数据").Cells(i, 1).Text & Worksheets(1).Cells(i, 2).Text Worksheets("输出").Cells(i + 1, 1).Value = str Next i End Sub