vba - Can I use a variable for n in Small(array,n) that increments inside a loop? Maybe a better method? -


i'm trying find smallest next smallest value range , return cell address each value in order smallest largest until largest found. example...if a1:i1 contained integer 1-9 in random order no duplicates, how can find cell address of cell 1, cell address value 2, etc. until cell address of 9 found? hoped use small , increment n variable in loop error. when step through routine "smaller = error 2029" when smallcount used in small function. if replace smallcount actual integer there's no issues. assistance appreciated....here's i'm at......

sub notworking()      loopcount = 9     smallcount = 1      while loopcount <> "0"          smaller = [cell("address",index(a1:i1,match(small(a1:i1,smallcount), a1:i1,0)))]          loopcount = loopcount - 1         smallcount = smallcount + 1     loop end sub  

i'm not quite sure goal may try code:

sub hopefullyworking()     dim long     dim col variant      range("a1:i1") ' <--| reference range         = 1 .count '<--| loop 1 referenced range cells number             col = application.match(worksheetfunction.small(.cells, i), .cells, 0) '<--| try finding current "small" number in referenced cells             if not iserror(col) msgbox "number " & & " found @ position " & col         next     end end sub 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -