Sub 合并单元格_Click() i = 1 startline = 1 endline = 1 Application.DisplayAlerts = 0 Do While Cells(i, 1) <> "" i = i + 1 If Cells(i, 1) <> Cells(i - 1, 1) Then endline = i - 1 rangeselect = "A" & startline & ":A" & endline Range(rangeselect).MergeCells = True 'Selection.Merge startline = i End If Loop Application.DisplayAlerts = 1 End Sub 我的代码未入门水平,这里是假设对A列进行合并
Sub test() 网页链接 = False For i = Cells(Rows.Count, 1).End(3).Row To 2 Step -1 If Cells(i, 1) = Cells(i - 1, 1) Then Cells(i - 1, 1).Resize(2, 1).Merge End If Next 网页链接 = True MsgBox "完成" End Sub