Help with formula

twiley23

New Member
Joined
Oct 15, 2007
Messages
42
I was looking to see how to assign a word to certain numbers and make them random. Also the word would need to have an assigned # of
How many times it will show up.

For example:

# Friday Saturday Sunday

1
2
3
4
5
6
7
8
9
10
11

The word bacon will only show up 1 time on either the number 2 or 10 and be placed under Friday, Saturday or Sunday randomly

The word eggs will show up 2 times on either number 1 or 11 and be placed under Friday or Saturday or Sunday randomly

Thanks , please let me know if this is even possible.
 
@twiley23 I have used the Copy icon (to left of Column letter A) to copy then paste my posted XL2BB solution back to a fresh sheet and it is working perfectly for me. No issue with allocating bacon or anything else.
Did you copy/paste the XL2BB ? Are your data ranges exactly the same? Maybe take a look to double check the formulas you have in rows 3 and 10.

If you continue to have issue then please download XL2BB and post back with your mini sheet showing what you have.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
@twiley23 I have used the Copy icon (to left of Column letter A) to copy then paste my posted XL2BB solution back to a fresh sheet and it is working perfectly for me. No issue with allocating bacon or anything else.
Did you copy/paste the XL2BB ? Are your data ranges exactly the same? Maybe take a look to double check the formulas you have in rows 3 and 10.

If you continue to have issue then please download XL2BB and post back with your mini sheet showing what you have.
Awesome !
Thank you , I will try when I get home , can I message you with some follow up questions ? Thanks
 
Upvote 0
Having had an update from @twiley23 as to the ‘rules’ he is trying to follow, here is a revised solution.
It’s a bit of a mix of worksheet formulas in helper columns and vba.
The vba is primarily to fix the values of what would otherwise be a load of volatile randomising functions.
Helper columns G, K & M still contain various formulas. . These remaining formulas could also be populated via vba if absolutely necessary. Helper columns can be hidden if required.

Book999.xlsm
ABCDEFGHIJKLMNO
1Dice #123WordsRandom RowRand Between For RowRow Option 1Row Option 2Random ColumnRandom # For ColumnRanked Random # For ColumnRand Between For ColumnDice #
22BACONBACON212222only row 2
33MUFFINTOASTPANCAKESBACON122121233only row 12
44BUTTEREGGS727722only row 7
55
66PANCAKES3131130.20361042323 or 11
77EGGSTOAST3131120.757638419223 or 11
88MUFFIN3131110.760053729123 or 11
990.3766820742
1010SYURPHONEYJAMBUTTER4141020.85021895714 or 10
1111HONEY10241020.21036217834 or 10
1212BACONJAM10241030.20890593324 or 10
13SYURP10241010.15085125634 or 10
140.3843623021
15OJ5159225 or 9
16
Sheet3
Cell Formulas
RangeFormula
G2:G4,G15,G10:G13,G6:G8G2=CHOOSE(H2,I2,J2)
K2:K4,K15K2=N2
K6:K8K6=IF(COUNTIF(G$6:G$8,G6)=1,N6,M6)
K10:K13K10=IF(G10=4,INDEX(M$9:M$11,COUNTIF(G$10:G10,G10)),INDEX(M$12:M$14,COUNTIF(G$10:G10,G10)))
M6:M8M6=RANK(L6,L$6:L$8,0)
M9:M11M9=RANK(L9,L$9:L$11)
M12:M14M12=RANK(L12,L$12:L$14)


VBA Code:
Sub RandPicks()
Dim Rng1 As Range
Dim Rng2 As Range
Dim RowVal As Range

Application.ScreenUpdating = False

'refresh helper columns requiring use of 'Volatile' Ranomising functions . Then fix values

'set randbetween for row picks
Set Rng1 = Union(Range("H2:H4"), Range("H6:H8"), Range("H10:H12"), Range("H15"))
Rng1.Formula = "=RANDBETWEEN(1,2)"
Rng1.Value = Rng1.Value
'set random numbers option for column pick
Range("L6:L14").Formula = "=RAND()"
Range("L6:L14").Value = Range("L6:L14").Value
'Set randbetween option for column pick
Set Rng2 = Union(Range("N2:N4"), Range("N6:N8"), Range("N15"))
Rng2.Formula = "=RANDBETWEEN(1,3)"
Rng2.Value = Rng2.Value
'set formula to limit max of 3 words picked in either roe 4 or row 10
Range("H13").Formula = "=IF(SUM(H10:H12)=(3*H10),CHOOSE(H10,2,1),RANDBETWEEN(1,2))"
Range("H13").Value = Range("H13").Value

'alllocate words
Range("B2:D12").ClearContents

For Each RowVal In Range(" G2:G13")
    If Not IsEmpty(RowVal) Then
    Cells(RowVal.Value, RowVal.Offset(0, 4).Value + 1) = RowVal.Offset(0, -1).Value
    End If
Next RowVal

Application.ScreenUpdating = True

End Sub

HTH
 
Upvote 0
@twiley23 !!! Just realised that the above code has a typo that will prevent the allocation of OJ

Edit the line For Each RowVal In Range(" G2:G13")

to read For Each RowVal In Range(" G2:G15")
 
Upvote 0

Forum statistics

Threads
1,225,732
Messages
6,186,704
Members
453,369
Latest member
positivemind

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