View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Set intersection on Excel spreadsheet?

Dim cell as Range, cell1 as Range
dim sStr as String
for each cell in Range(A1:A3)
for each cell1 in Range("B1:B4)
if cell = cell1 then
sStr = sStr & cell & ", "
end if
next
Next
sStr = Left(sStr,len(sStr)-2)
msgbox sStr

You would have to add code if there will be duplicate numbers within a
single range.

--
Regards,
Tom Ogilvy


"Tim" <tim@smi wrote in message
...
I need a way to get the set intersection of two ranges of
cells on an
Excel spreadsheet. For example, if one range of cells has
the values 1,
2, 3 and another range has the values 1,3,5,6 then the
intersetion
function on these two ranges would return 1,3.
Any suggestions?