View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Delete Matched Cells


Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long
Dim FindRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
If .Cells(i, "A").Value < "" Then
FindRow = 0
On Error Resume Next
FindRow = Application.Match(.Cells(i, "A"), .Columns(3), 0)
On Error GoTo 0
If FindRow 0 Then
.Cells(FindRow, "C").Value = .Cells(FindRow, "C").Value
.Cells(i, "A").Value = ""
End If
End If
If .Cells(i, "B").Value < "" Then
FindRow = 0
On Error Resume Next
FindRow = Application.Match(.Cells(i, "B"), .Columns(3), 0)
On Error GoTo 0
If FindRow 0 Then
.Cells(FindRow, "C").Value = .Cells(FindRow, "C").Value
.Cells(i, "B").Value = ""
End If
End If
Next i

LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
If LastRow = i Then
For i = i To LastRow
On Error Resume Next
FindRow = Application.Match(.Cells(i, "B"), .Columns(3), 0)
On Error GoTo 0
If FindRow 0 Then
.Cells(FindRow, "C").Value = .Cells(FindRow, "C").Value
.Cells(i, "B").Value = ""
End If
Next i
End If

End With

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"scott" wrote in message
...
LISTING 1 below shows a range of A1:C9 where the values in column C are a
formula that finds values that are equal in column A and B. I need a way
to go down column A and B and delete any cells that are "matched" in
Column C. The trick here is once a cell is deleted in Column A for example
that has a match in Column B, I must remember that value because the value
will no longer exist in Column C because it's values are derived by a
matching formula.

Can someone help me create a Do While statement that goes down Column C
and deletes any cells in Column A and B that appear in Column C?

Note: The number of rows will constantly be changing, so the Range will
always vary. Also, Row 2 is blank, but I have a line shown below.

Any help would be appreciated.


LISTING 1:

BOL Billed Matched
--------------------------------
199111 196711
198199 198199
198100 198100 198100
196699
196711 196711
196699 196699
196694 198199