excel - Top 20 vba, large returning double, instead of decimal -
i looking retrieve top 20 values array of thousands of lines. however, worksheet function large retrieving double rather decimal, in other words, search item coming 2.1110000, though value should 0.0021110000. huge problem because when search not finding values.
ideally, code identify top 20 values in array , retrieve values columns @ same row number top 20 values.
sub top20() dim c bk.range("a18") = "top20": bk.range("a19") = "cnumber": bk.range("b19") = "it": bk.range("c19") = "sn": bk.range("d19") = "c": bk.range("e19") = "p" = 1 20 fltarr = wrk.range("al2:al" & wrk.range("a1").end(xldown).row) wrk.range("al:al") searchitem = (worksheetfunction.large(arg1:=fltarr, arg2:=i)) set c = .find(searchitem) if not c nothing bk.range("a20").offset(i, 0) = wrk.range("b" & c.row) bk.range("a20").offset(i, 1) = wrk.range("f" & c.row) bk.range("a20").offset(i, 2) = wrk.range("g" & c.row) bk.range("a20").offset(i, 3) = wrk.range("h" & c.row) bk.range("a20").offset(i, 4) = wrk.range("j" & c.row) end if end next bk.range("a16") = "top20p": bk.range("a27") = "cn": bk.range("b27") = "it": bk.range("c27") = "sn": bk.range("d27") = "c": bk.range("e27") = "p" = 1 20 wrk.range("am:am") set c = .find(worksheetfunction.sum(worksheetfunction.large(bk.range("al:al"), (i)))) if not c nothing bk.range("a27").offset(i, 0) = wrk.range("b" & c.row) bk.range("a27").offset(i, 1) = wrk.range("f" & c.row) bk.range("a27").offset(i, 2) = wrk.range("g" & c.row) bk.range("a27").offset(i, 3) = wrk.range("h" & c.row) bk.range("a27").offset(i, 4) = wrk.range("j" & c.row) end if end next end sub
Comments
Post a Comment