excel vba - compare values in two cells even if the values are not in same order -
i have 2 columns , b. value in cell a1 "abc, def, ghi" , value in cell b1 "ghi, abc, def". cells contain same values . however, not in same order . if a1=b1 used false. how right .
try following user defined function:
public function samestuff(s1 string, s2 string) boolean dim bad boolean samestuff = false ary1 = split(replace(s1, " ", ""), ",") ary2 = split(replace(s2, " ", ""), ",") if ubound(ary1) <> ubound(ary2) exit function each a1 in ary1 bad = true each a2 in ary2 if a1 = a2 bad = false next a2 if bad = true exit function next a1 samestuff = true end function
for example:
note:
- the space character discarded
- there can more 3 items in each cell.
- true means items in b1 permutation of items in a1
Comments
Post a Comment