|
发表于 2013-3-17 23:23
|
显示全部楼层
本楼为最佳答案
好像是这样的结果??
- Sub cc()
- Dim Rg As Range, S As String
- Dim X As Long, Hx As Long, H As Long
- With Sheets("Sheet3")
- X = .Range("A65536").End(xlUp).Row
- For Hx = 2 To X
- S = .Cells(Hx, "A").Value
- Set Rg = .Range(.Cells(Hx + 1, "A"), .Cells(X, "A"))
- If ChaZhao(Rg, S) Then
- H = H + 1
- .Cells(H, "C").Value = S
- ElseIf Not ChaZhao(.Range("B:B"), S) Then
- H = H + 1
- .Cells(H, "C").Value = S
- End If
- Next
- X = .Range("B65536").End(xlUp).Row
- H = 0
- For Hx = 2 To X
- S = .Cells(Hx, "B").Value
- If Not ChaZhao(.Range("A:A"), S) Then
- H = H + 1
- .Cells(H, "D").Value = S
- End If
- Next
- End With
- End Sub
- Function ChaZhao(ByVal Rng As Range, ByVal What As Variant)
- Dim C As Range
- Set C = Rng.Find(What, , , 1)
- ChaZhao = Not C Is Nothing
- End Function
复制代码 |
|