View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Knut Dahl Knut Dahl is offline
external usenet poster
 
Posts: 11
Default Comparing two ranges and extracting non duplicate data

Wow, works brilliantly.
You are a star. Thanks a million.

Regards

kj

"Tom Ogilvy" wrote in message
...
Dim rng as Range, rw as Long
Dim rngA as Range, cell as Range
set rngA = Range(cells(1,"A"),Cells(rows.count,"A").End(xlup) )
set rng = Range(cells(1,"D"),cells(rows.count,"D").End(xlup) )
rw = 1
for each cell in rng
if application.Countif(rngA,cell.Value) = 0 then
cells(rw,"F").Value = cell.Value
rw = rw + 1
end if
Next

--
Regards,
Tom Ogilvy

"Knut Dahl" wrote in message
...
Thanks Tom,
can I use this in VBA code as well? I need this to be part of a bigger
procedure that I'm currently writing.
Thanks ;)

KJ

"Tom Ogilvy" wrote in message
...
in F1 put the formula
=if(countif(A:A,D1)=0,D1,"")

then drag fill down the column.

--
Regards,
Tom Ogilvy

"Knut Dahl" wrote in message
...
Good morning everyone.
I am currently trying to compare 2 ranges with each other.
One range is in column A and the other in column D.
Column D contain more data than Column A. I want to compare the 2

ranges
with each other and then extract all the data that are in column D,
but
not
in column A and put them in a new column (F for example).
It might sound really easy, but I have tried various if...then and
do...while constructs, but it looks like I'm stuck logically.
Does anyone have a clever idea of how to solve this?
Any help is greatly apreciated.

Thanks guys

KJ