代码供参考。。。
- Sub ykcbf() '//2024.9.19 A、B列比较
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 4)
- For i = 1 To UBound(arr)
- If arr(i, 1) = arr(i, 2) Then
- arr(i, 4) = "相同"
- Else
- arr(i, 4) = "格式不同"
- End If
- Next
- .[d1].Resize(r, 1) = Application.Index(arr, 0, 4)
- End With
- End Sub
- Sub ykcbf2() '//2024.9.19 A、B列做成一样
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 2)
- For i = 1 To UBound(arr)
- arr(i, 1) = CStr(arr(i, 1))
- arr(i, 2) = CStr(arr(i, 2))
- Next
- .[a1].Resize(r, 2) = arr
- End With
- End Sub
复制代码
|