Hi,
I wrote the following formula in cell F2: IFERROR(INDEX(DW.Data!1:1,0,MATCH(M1,DW.Data!1:1,0)),0).
For the row option of the index formula, I need to add some logic that will basically choose a random row to return among ONLY rows that have values. The column will have maybe 10,000 rows with 9,652 rows being blank (no value) and 348 rows have a value. The values within the row will be noncontiguous.
I need the above formula to offset and choose any random cell containing a value and return it.
I've attached an example. THANKS FOR ALL YOUR HELP!!
Last edited by John Bates; 03-16-2010 at 06:04 PM. Reason: SOLVED
Maybe this one
=INDEX(B2:B10000,SMALL(IF(B2:B10000<>"",ROW(INDIRECT("1:"&ROWS(B2:B10000)))),RANDBETWEEN(1,SUM((B2:B 10000<>"")*1))))
Confirm with ctrl + Shift + enter
Люди, питающие благие намерения, как раз и становятся чудовищами.
Regards, «Born in USSR»
Vusal M Dadashev
Baku, Azerbaijan
This seems to work:
confirmed with CTRL+SHIFT+ENTERCode:=INDEX(B2:B10000,SMALL(IF(B2:B10000<>"",ROW(B2:B10000)-ROW(B2)+1),RANDBETWEEN(1,COUNTIF(B2:B10000,"*?"))))
You have some cells in B range with 0, remove those.. or you may get 0 returned sometimes.
Last edited by NBVC; 03-16-2010 at 05:04 PM. Reason: Added note concerning 0's found in B2:B10000
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
i'd opt for a helper column in say col b
if(a1>0,rand(),"") dragged down then match for use in the index row criteria as MATCH(MIN(B1:B10000),B1:B10000,0) [or MATCH(max(B1:B10000),B1:B10000,0)]
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
The array formula takes mere milliseconds to refresh upon hitting F9.
If you have many other formulas evaluating in the sheet or if you have lots more than 10000 rows, then perhaps helper column would be more ideal....
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Perfect, thank you for both of your help. I ended up using contaminated's array formula for this particular problem though both worked equally well.
Thanks again!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks