excel vba - Select Cells with Value Greater than Zero -
i have column of values , want select cells greater 0:

i tried looking online not find solution. how can vba script, preferably without writing loop?
thank you!
maybe this:
option explicit sub main() dim ws worksheet, i&, arr() long, rng range set ws = thisworkbook.sheets("sheet1") redim arr(0) call nonzeroselection(activesheet, i, arr, rng) end sub sub nonzeroselection(byref ws worksheet, byref i&, byref arr() long, rng range) dim lr&, ix$ lr = ws.range("a" & rows.count).end(xlup).row = 1 lr set rng = ws.range("a" & i) if rng.value = "0" redim preserve arr(ubound(arr) + 1) arr(ubound(arr) - 1) = end if set rng = nothing next redim preserve arr(ubound(arr) - 1) = lbound(arr) ubound(arr) ix = ix & arr(i) & ":" & arr(i) & "," next ix = left(ix, len(ix) - 1) ws.range(ix).select end sub
Comments
Post a Comment