excel表中如何合并相同的数据 其他的内容都保留,excel怎么把重复的数据合并在一起

首页 > 生活 > 作者:YD1662025-06-02 07:58:20

excel表中如何合并相同的数据 其他的内容都保留,excel怎么把重复的数据合并在一起(1)

可以用vba实现。代码如下。Sub 合并() Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next m = [E65536].End(xlUp).Row x = Cells(2, 5): j = 1: z = 0 For i = 3 To m y = Cells(i, 5) If x y Then x = y If j > 1 Then Range(Cells(z, 5), Cells(z + j - 1, 5)).MergeCells = True: j = 1 Else j = j + 1 If j = 2 Then z = i - 1 End If Next i Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "相同数据合并完成!"End Sub

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.