我有一个看起来像这样的 Excel 格式:
我需要的是 Excel 中的 VBA 代码,它将读取 A 列中的所有数据并查找斜体格式的任何文本,然后检查同一列上是否有重复数据。如果是,则该数据将写入 B 列。
这是我到目前为止所拥有的:
Sub FillDuplicates()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row 'find last row in column A
For x = 1 To lastrow
If Cells(x, 2).Value <> "" Then 'Check if cell in column B is empty
For y = 1 To lastrow
If Cells(y, 1).Value = Cells(x, 1).Value Then 'Compares cell against each value in column A
Cells(y, 2).Value = Cells(x, 2).Value 'If matches, add value in column B
End If
Next y
End If
Next x
End Sub