How to check that multiple values are not equal in VBA? -


i want print list of 8 numbers worksheet, if unique.

an ideal code along lines of

if <> b <> c 

rather than

if <> b , <> c , b <> c 

is possible, given values called array using code following:

cells(2, 8) = numarr(i) cells(2, 9) = numarr(j) cells(2, 10) = numarr(k) cells(2, 11) = numarr(l) cells(3, 8) = numarr(m) cells(3, 9) = numarr(n) cells(3, 10) = numarr(o) cells(3, 11) = numarr(p) 

thanks!

the quick , dirty way dictionary, requires unique key. keep dumping numbers in array until hit 1 that's in dictionary. make function , pass array it:

private function allunique(incoming variant) boolean      if not isarray(incoming) err.raise 13      dim candidates scripting.dictionary     set candidates = new scripting.dictionary      dim index long     index = lbound(incoming) ubound(incoming)         if candidates.exists(incoming(index)) exit function         candidates.add incoming(index), index     next index      allunique = true  end function 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -