ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set intersection on Excel spreadsheet? (https://www.excelbanter.com/excel-programming/278640-re-set-intersection-excel-spreadsheet.html)

Tom Ogilvy

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?







All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com