Random selection from range where the selection is constrained of whether or not another cell on the same row ISTEXT

dailan

New Member
Joined
Oct 7, 2016
Messages
20
Dear folks,

hope that all is well. I have a frustrating problem with a random selection from a range given that another cell on the same row is text/not blank.
Below table might help to explain the circumstances. What I would like to do is to select a row completely random, constrained on the fact that the dealer can't be blank/must be text. And then I would like to retrieve the values from the stochastically selected row. Hopefully it makes sense what I would like to do.


IDDealerPosType
122PS1000Buy
444DS1500Buy
3211000Sell
123TS1000Buy

<tbody>
</tbody>
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Dailan,

If you'll allow me a worker column and a cell to get the RANDBETWEEN result then this should work.

ABCDEFGHIJKL
1IDDealerPosTypeCountRowIDDealerPosType
2122PS1000Buy14123TS1000Buy
3444DS1500Buy2
43211000Sell
5123TS1000Buy3

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
I2=INDEX(A$2:A$5,$G$2)
F2
=IF(B2="","",MAX($F$1:$F1)+1)
G2=MATCH(RANDBETWEEN(1,MAX($F$2:$F$5)),$F$2:$F$5,0)
F3
=IF(B3="","",MAX($F$1:$F2)+1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Dear Toadstool,

hope that all is well.

Many thanks for the reply. Seems to be working.So a thousand thanks to you!
Just if you have the interest/time; I'm a bit reluctant to adding calculated columns since it generally makes the file a bit too slow (it's a big file). Trying to create an array formula that would cope with the issue, but when trying it i get a "1" since the ranking of each line receives a "1" in value. Would you happen to know a way of also solving this?

{=RANDBETWEEN(1;MAX(IF(B2:B2000=""; ""; MAX($B$1:$B1)+1);IF(B2:B2000=""; ""; MAX($B$1:$B1)+1)))
}


Thanking again in advance!

Kind regards

Dailan
 
Last edited:
Upvote 0
Dailan,

Well the formula I proposed to copy down for each row isn't an array formula so will run quickly: =IF(B2="","",MAX($F$1:$F1)+1)

I can't see how to do this in one array formula (e.g. the RANDBETWEEN must run just once so it must return the target row number) but maybe another forum member can see it?

Sorry,
Toadstool
P.S. I see you have semicolon delimiters so suspect you're using OpenOffice Calc. I would recommend LibrOffice Calc as I believe it to be more robust and it allows you to change the Function delimiter by going to Tools, Options, LibreOffice Calc, Formula, Separators
 
Upvote 0
For reference, a lot of European countries use a ; rather than a , as the delimiter.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top