Excel VBA: 删除单元格 A 与 B 连续相同字符
Sub RemoveDuplicates() Dim lastRow As Long Dim i As Long, j As Long Dim strA As String, strB As String, strC As String
lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastRow - 1
strA = ActiveSheet.Cells(i, "A")
strB = ActiveSheet.Cells(i + 1, "B")
strC = ""
For j = 1 To Len(strA)
If Mid(strA, j, 1) = Mid(strB, j, 1) Then
strC = strC
Else
strC = strC & Mid(strA, j, 1)
End If
Next j
ActiveSheet.Cells(i, "C") = strC
Next i
End Sub
原文地址: https://www.cveoy.top/t/topic/mJQH 著作权归作者所有。请勿转载和采集!