Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ned ned is offline
external usenet poster
 
Posts: 1
Default compare columns

hi all

I have column A and B in the same wsheet. I need to scan each cell in
column A and find if the cell in A matches with any cell in column C ,
if it does not match any of the cells in B, I want to write the text of
the A cell to column C.

Where can I find some examples?


thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default compare columns

Ned,

Here's one way:

Sub Test()
Dim lRow As Long
Dim rng As Range, i As Range, xRng As Range

lRow = Range("A65536").End(xlUp).Row
Set rng = Range(Cells(1, 2), Cells(lRow, 2))

For Each i In rng
Set xRng = rng.Find(What:=i.Offset(0, -1).Value, _
LookIn:=xlValues, MatchCase:=False)
If xRng Is Nothing Then
i.Offset(0, -1).Copy i.Offset(0, 1)
End If
Next i

End Sub

--
Dan Oakes

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default compare columns

This could be done with a simple worksheet function. With data in columns
$A and $B, put the following formula in cell $C$1 and fill down the extent
of the range. This example has data in $A$1:$B25. Cells in column $A that
can be found in column $B will have a blank string ("") in column $C.

=IF(ISNA(MATCH(A1,$B$1:$B$25,0)),A1,"")

--
Regards,
Bill Renaud



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare two columns pm Excel Discussion (Misc queries) 7 July 3rd 08 09:59 PM
compare 2 columns BettysAnswer Excel Worksheet Functions 1 January 27th 06 09:46 PM
Compare all following columns when value is same Allison Excel Programming 4 October 9th 04 12:03 AM
Compare columns of value fl Excel Programming 1 August 4th 04 07:46 PM
Compare to columns fl Excel Programming 1 August 4th 04 07:46 PM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"