Excel2013,怎么合并重复文本值的两行,如图。
发布网友
发布时间:2023-10-29 16:17
我来回答
共2个回答
热心网友
时间:2024-11-15 12:01
Sub MergeDuplicate()
col_hankou = 4
row_first = 2
row_end = 1024
row_next = 0
For i = row_first To row_end
If Cells(i, col_hankou) = "" Then Exit Sub
row_next = i + 1
If Cells(i, col_hankou) = Cells(row_next, col_hankou) Then
'将重复的第二行复制到重复的第一行
If Cells(row_next, col_hankou - 1) <> "" Then
For j = col_hankou - 1 To 1 Step -1
Cells(i, j) = Cells(row_next, j)
Next
End If
If Cells(row_next, col_hankou + 1) <> "" Then
For j = 1 To 5
Cells(i, col_hankou + j) = Cells(row_next, col_hankou + j)
Next
End If
'删除第二行
Cells(row_next, col_hankou).EntireRow.Delete
End If
Next
End Sub
热心网友
时间:2024-11-15 12:01
INDEX函数可以实现