excel - Strange #VALUE! error -
here 2 functions:
public function compareextra(r1 range, r2 range) long dim r integer, v variant, v2 variant dim rr1() string dim rr range rr1 = split(r1, ",") r = lbound(rr1) ubound(rr1) v = --trim(rr1(r)) if v <> 0 , v <> "" each rr in r2 v2 = rr.value if v = v2 compareextra = compareextra + 1 next rr end if next r end function function getleast(rng range, leastxvalues long, maxvalue long, displacement long, optional sorted boolean = true) string dim d object, al object dim long, j long dim variant set d = createobject("scripting.dictionary") set al = createobject("system.collections.arraylist") = rng.value = ubound(a, 1) j = ubound(a, 2) if a(i, j) <> 0 d(a(i, j)) = a(i, j) j = j - 1 if j = 0 j = ubound(a, 2) = - 1 end if loop until = 0 = 1 maxvalue d(i) = next = d.items() = ubound(a) - displacement ubound(a) - displacement - leastxvalues + 1 step -1 al.add a(i) next if sorted al.sort getleast = join(al.toarray, ", ") end function
i can't why if take result of getleast() separate cell - works, if add compareextra() directly, throws error..
simple solution use variants:
public function compareextra(r1 variant, r2 variant) long function getleast(rng range, leastxvalues long, maxvalue long, displacement long, optional sorted boolean = true) variant
Comments
Post a Comment