|
- Sub 合并表格()
- Dim lLastrow As Long
- Dim i As Long, j As Long
- Dim arr
- Dim arrResult()
- Dim strMerge As String
-
- lLastrow = Cells(Rows.Count, 2).End(xlUp).Row
- arr = Range("b2:f" & lLastrow)
- ReDim arrResult(1 To UBound(arr), 1 To 2)
- arrResult(1, 1) = "日期"
- arrResult(1, 2) = "事项"
-
- Application.ScreenUpdating = False
- For i = 2 To UBound(arr)
-
- strMerge = ""
- For j = LBound(arr) + 1 To UBound(arr, 2)
- If Len(arr(i, j)) > 0 Then
- strMerge = strMerge & arr(1, j) & ":" & arr(i, j) & ";"
- End If
- Next
- If Len(strMerge) > 0 Then
-
- arrResult(i, 1) = arr(i, 1)
- strMerge = Left(strMerge, Len(strMerge) - 1) & "。"
- arrResult(i, 2) = strMerge
- End If
- Next
-
- Columns("h:j") = ""
- Range("h2").Resize(i - 1, j - 1) = arrResult
- Application.ScreenUpdating = True
- MsgBox "合并完成"
- End Sub
复制代码 |
|