View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default How to compare two columns for a specified string?

Use a loop through column C
(code not tested)

====================================
Dim x as Long, lrw as Long

lrw = Cells(Rows.COUNT, "C").End(xlUp).Row

For x = 1 to lrw
If worksheetfunction.countif(Columns(1), Cells(x,3)) = 0 then
Range(cells(x,3),cells(x,4)).ClearContents
End If
Next
===========================================
or delete the cells
Range(cells(x,3),cells(x,4)).Delete Shift:=xlUp

Be sure to work from the bottom up...
For x = lrw to 1 step -1
--
steveB

Remove "AYN" from email to respond
"jarski" wrote in message
oups.com...
Could someone help me on the following?

Column A contains a list of string values and so does column C. The
strings in both columns have corresponding numerical values in columns
B and D. I need a routine (macro?) that cheks if a certain string
exists in both columns A and C.If the same string is found in both,
nothing else is done and if a certain
string is only found in column C, that string and the corresponging
value in column D are deleted. The procedure should be repeated until
the lists contain the only the same strings. In other words the goal is
that both lists would become identical, ie the strings in column C
missing from column A would be deleted.


Thanks,
jarmo