SOLVED

Random selection for raffle winners

%3CLINGO-SUB%20id%3D%22lingo-sub-1747967%22%20slang%3D%22en-US%22%3ERandom%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1747967%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20running%20an%20online%20event%20where%20I%20will%20have%20a%20list%20of%20raffle%20purchasers.%20I%20have%20seen%20in%20previous%20settings%20where%20excel%20has%20the%20functionality%20to%20run%20a%20program%20to%20select%20a%20winner%20randomly.%20One%20can%20see%20the%20program%20scrolling%20through%20all%20the%20names%20and%20then%20eventually%20landing%20on%20a%20winner.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20tell%20me%20how%20to%20run%20such%20a%20program%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1747967%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1748954%22%20slang%3D%22de-DE%22%3ESubject%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748954%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821368%22%20target%3D%22_blank%22%3E%40Maree29%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22text-wrap%20tlid-copy-target%22%3E%3CDIV%20class%3D%22result-shield-container%20tlid-copy-target%22%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3EWith%20your%20permission%2C%20if%20I%20can%20recommend%20you%2C%20add%20a%20file%20(without%20sensitive%20data)%20to%20your%20project.%3CBR%20%2F%3EExplain%20your%20plans%20in%20relation%20to%20this%20file.%3CBR%20%2F%3ESo%20you%20can%20get%20a%20solution%20that%20is%20tailored%20to%20your%20needs%20much%20faster.%3CBR%20%2F%3EAt%20the%20same%20time%2C%20it%20is%20much%20easier%20for%20someone%20who%20wants%20to%20help%20understand%20the%20subject.%3CBR%20%2F%3EA%20win-win%20situation%20for%20everyone.%3CBR%20%2F%3E%3CBR%20%2F%3EHere%20is%20a%20VBA%20suggestion.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20list%20of%20names%20in%20column%20A%20can%20be%20of%20any%20length%2C%20but%20must%20begin%20in%20A1.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20second%20macro%20builds%20in%20the%20button%20to%20trigger%20the%20first%20macro.%3CBR%20%2F%3E%3CBR%20%2F%3ECode%3A%20%3CBR%20%2F%3E%20Sub%20raffle%20()%20%3CBR%20%2F%3E%20Dim%20rngBer%20As%20Range%20%3CBR%20%2F%3E%20Dim%20lngZ%20As%20Long%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20Randomize%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20lngZ%20%3D%20Cells%20(Rows.Count%2C%201)%20.End%20(xlUp)%20.Row%20%3CBR%20%2F%3E%20Set%20rngBer%20%3D%20Range%20(Cells%20(1%2C%201)%2C%20Cells%20(lngZ%2C%201))%20%3CBR%20%2F%3E%20lngZ%20%3D%20CLng%20(Int%20(lngZ%20*%20Rnd%20%2B%201))%20%3CBR%20%2F%3E%20Cells%20(lngZ%2C%201)%20.Offset%20(0%2C%201)%20.Value%20%3D%20Cells%20(lngZ%2C%201)%20.Offset%20(0%2C%201)%20.Value%20%2B%201%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20End%20Sub%20'****************************************************%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20*%20Sub%20button%20%3CBR%20%2F%3E%20()%20With%20%3CBR%20%2F%3E%20ActiveSheet.Buttons.Add%20(243%2C%2024%2C%20104.25%2C%2045)%20%3CBR%20%2F%3E%20.OnAction%20%3D%20%22Raffle%22%20%3CBR%20%2F%3E%20.Characters.Text%20%3D%20%22Start%22%20%3CBR%20%2F%3E%20End%20With%20End%20Sub%20If%20you%20click%20the%20button%20with%20the%20right%20mouse%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20button%2C%20you%20can%20move%20it%20to%20any%20position.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22result-shield-container%20tlid-copy-target%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22result-shield-container%20tlid-copy-target%22%3E%3CP%3EI%20would%20be%20happy%20to%20know%20if%20I%20could%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%20class%3D%22tlid-result-transliteration-container%20result-transliteration-container%20transliteration-container%22%3E%3CDIV%20class%3D%22tlid-transliteration-content%20transliteration-content%20full%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1748990%22%20slang%3D%22de-DE%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748990%22%20slang%3D%22de-DE%22%3ESelect%20random%20generator%20from%20different%20names%20Additional%20information%20with%20formula%3A%20On%20this%20page%20you%20will%20find%20information%20on%20how%20you%20can%20do%20this%20with%20formulas%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F2768-excel-select-random-names.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F2768-excel-select-random-names.html%3C%2FA%3E%20I%20would%20be%20happy%20to%20know%20if%20I%20could%20help.%20Nikolino%20I%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1752168%22%20slang%3D%22de-DE%22%3ESubject%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1752168%22%20slang%3D%22de-DE%22%3EYou%20are%20welcome%20%3CBR%20%2F%3E%20I%20was%20pleased%20to%20be%20able%20to%20help%20you.%3CBR%20%2F%3E%3CBR%20%2F%3ENikolino%20%3CBR%20%2F%3E%20I%20know%20that%20I%20know%20nothing%20(Socrates)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1769930%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1769930%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722750%22%20target%3D%22_blank%22%3E%40Nikolino%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDear%20Nikolino%2C%20I%20am%20afraid%20the%20random%20function%20is%20not%20appropriate.%20I%20am%20not%20a%20'coder'%20as%20such%20I%20need%20a%20formula%20that%20will%20provide%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20have%20120%20Melb%20Cup%20Sweep%20purchasers%20and%20I%20have%2024%20horses%20in%20the%20race%2C%20If%20all%20these%2024%20horses%20names%20were%20put%20into%20a%20hat%20and%20each%20purchasers%20pulled%20out%20a%20name%2C%20I%20need%20for%20the%2024%20horse%20names%20to%20be%20randomly%20allocated%20to%20the%20120%20purchasers.%20There%20are%203%20placings%20-%201st%2C%202nd%20%26amp%3B%203rd.%20When%20the%20race%20is%20run%2C%20there%20should%20be%205%20people%20with%20the%20winning%20horse%2C%205%20people%20who%20get%20second%20and%205%20people%20who%20get%20third.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20need%20a%20formula%20that%20firstly%20allocates%20the%2024%20horses%20to%20the%20purchasers%20but%20I%20need%20this%20to%20replicate%20as%20if%20they%20were%20being%20picked%20out%20of%20hat.%20So%20the%20Random%20function%20may%20not%20work%20as%20it%20doesn't%20do%20this.%20Plus%20it%20keeps%20changing%20the%20random%20number%20allocated%20which%20is%20not%20what%20I%20want.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20thought%20I%20might%20just%20allocate%20the%20horses%20to%20the%20purchasers%20based%20on%20date%20of%20purchase%20starting%20at%20Horse%201%3C%2FP%3E%3CP%3ESee%20my%20file%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1770079%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1770079%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821368%22%20target%3D%22_blank%22%3E%40Maree29%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20you%20can%20do%20that%20with%20a%20circular%20reference%20and%20with%20iterative%20calculation%20turned%20on%20(File%2FOptions%2FFormulas%20-%20Enable%20iterative%20calculation%20-%20I%20set%20mine%20for%20200).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20generate%20a%20new%20list%2C%20you%20can%20change%20the%20%22Reset%22%20drop%20down%20to%20TRUE%2C%20then%20hold%20down%20the%20F9%20(calculate)%20key%20for%20a%20few%20seconds%20to%20randomize%20the%20list.%20Then%2C%20change%20the%20%22Reset%22%20to%20FALSE%20and%20hit%2Fhold%20the%20F9%20key%20until%20each%20horse%20appears%205%20times%20(the%20%22Condition%20Met%22%20cell%20should%20change%20to%20TRUE).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20it%20were%20me%2C%20once%20the%20list%20is%20generated%2C%20I%20would%20copy%2Fpaste%20special%20value%20the%20list%20to%20another%20worksheet%20just%20to%20ensure%20I%20didn't%20accidentally%20trigger%20the%20formulas%20to%20recalculate%20later%20and%20cause%20the%20list%20to%20be%20re-shuffled.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1773482%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1773482%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20sorry%20to%20bother%20you%20again%20but%20can%20you%20tell%20me%20how%20to%20do%20the%20second%20part%3C%2FP%3E%3CP%3Eie.%20Reset%20dropdown.%20I%20can't%20locate%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20might%20be%20easier%20if%20you%20could%20make%20the%20change%20in%20the%20file%20that%20I%20sent.%20And%20I%20agree%20moving%20the%20final%20horse%20list%20to%20a%20new%20worksheet%20is%20what%20I%20would%20do%20also.%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1773627%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1773627%22%20slang%3D%22en-US%22%3EIf%20you%20click%20on%20cell%20B1%2C%20you%20should%20see%20a%20drop%20down%20button%20with%20True%2FFalse%20options.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1778160%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1778160%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3BHi%20Again%2C%20you%20are%20so%20clever.%20I%20would%20never%20have%20been%20able%20to%20work%20that%20out.%20I%20got%20the%20spreadsheet%20to%20output%205%20horses%20for%20the%20selected%20buyers.%20So%20if%20I%20end%20up%20with%20say%20300%20buyers%20do%20I%20have%20to%20change%20the%20settings%20in%20formulas.%20You%20had%20put%20a%20setting%20at%20200.%20Will%20I%20need%20to%20change%20that%20depending%20on%20the%20number%20of%20buyers%20I%20end%20up%20with%20%3F%3C%2FP%3E%3CP%3EIs%20there%20anything%20else%20I%20should%20know.%20To%20ensure%20I%20don't%20mess%20up%20your%20formulas%2C%20I%20will%20just%20amend%20your%20spreadsheet%20and%20copy%20the%20buyer%20names%20to%20column%20A.%20If%20then%20I%20just%20update%20the%20Horse%20List%20values%20with%20the%20actual%20horse%20name%2C%20once%20I%20know%20it%2C%20will%20that%20impact%20the%20formulas.%20I%20am%20hoping%20not%20since%20it%20is%20referencing%20a%20cell.%3C%2FP%3E%3CP%3EIt%20seems%20so%20much%20easier%20to%20cut%20up%20the%20names%20and%20put%20them%20in%20a%20hat.%20We%20would%20be%20doing%20that%20if%20we%20weren't%20living%20with%20a%20pandemic%20!!%20Thankyou%20so%20much%20for%20your%20help.%20You%20are%20amazing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1789118%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1789118%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821368%22%20target%3D%22_blank%22%3E%40Maree29%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%20it%20took%20me%20a%20little%20while%20to%20get%20back%20to%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20modified%20the%20workbook%20to%20use%20structured%20tables%2C%20which%20will%20make%20the%20lists%20easier%20to%20resize%20(Table%20Tools%20tab%2C%20Resize)%20and%20add%20more%20entries.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20I%20changed%20the%20formulas%20to%20use%20structured%20table%20references%2C%20so%20you%20should%20not%20have%20to%20change%20the%20formulas%20after%20resizing%20and%20changing%20your%20customer%2Fhorse%20lists.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20added%20a%20workbook%20open%20macro%20to%20turn%20on%20iterative%20calculation%20to%20save%20you%20a%20step%20(just%20don't%20save%20the%20workbook%20as%20an%20xlsx%20file%20as%20that%20will%20strip%20out%20the%20macros).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1792512%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1792512%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%20Hi%20again.%20I%20got%20it%20to%20work%20well%20when%20the%20number%20of%20buyers%20was%20equally%20divisable%20by%2024.%20But%20when%20it%20was%20an%20odd%20number%20such%20as%20below%20I%20had%20issues.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20resized%20the%20table%20to%20207%20sweeps%20buyers%20and%20followed%20your%20instructions%20but%20for%20some%20reason%20there%20are%20some%20gaps%20from%20Sweeps%20buyers%20193%20-%20207.%20These%20final%20rows%20remained%20as%20false.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerhaps%20to%20make%20this%20work%2C%20I%20will%20need%20to%20sell%20the%20number%20of%20sweeps%20tickets%20that%20will%20make%20it%20divisable%20by%2024%20exactly%20since%20I%20am%20trying%20to%20replicate%20what%20happens%20in%20the%20real%20world%20of%20'sweeps'.%3C%2FP%3E%3CP%3EYou%20have%20been%20a%20terrific%20help%20to%20me%20in%20this%20so%20thanks.%26nbsp%3B%20When%20we%20get%20closer%20to%20the%20date%20I%20will%20come%20back%20to%20you%20with%20how%20I%20am%20going%20with%20the%20number%20of%20sales.%20I%20have%20put%20a%20deadline%20of%2012%20noon%20on%20Mon%202nd%20Nov%20for%20me%20to%20finalise%20allocations%20then%20I%20am%20going%20to%20send%2024%20emails%20to%20the%20buyers%20advising%20them%20of%20their%20horse.%20The%20race%20itself%20takes%20place%20the%20following%20day%20on%20Tues%203rd%20Nov.%20Fun%20hey%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1793963%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1793963%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821368%22%20target%3D%22_blank%22%3E%40Maree29%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%2C%20I%20assumed%20all%20horses%20would%20be%20equally%20allocated.%20With%20207%20sweeps%20buyers%20and%2024%20horses%2C%20each%20horse%20should%20be%20allocated%208%20times%20with%2015%20horses%20allocated%209%20times%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20reworked%20it%20to%20accommodate%20this%20remainder.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1794016%22%20slang%3D%22en-US%22%3ERE%3A%20Random%20selection%20for%20raffle%20winners%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1794016%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20again%2C%20I%20am%20putting%20this%20spreadsheet%20through%20the%20hoops%20but%20I%20think%20it%20is%20great.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20extended%20the%20number%20of%20buyers%20to%20212%20sweeps%20buyers%20by%20dragging%20the%20last%20few%20rows%20down%20but%20when%20I%20hold%20the%20F9%20key%20it%20came%20up%20with%20an%20error%20to%20do%20with%20a%20circular%20reference.%20I%20still%20think%20the%20result%20was%20correct%20though.%26nbsp%3B%20It%20might%20have%20something%20to%20do%20with%20how%20I%20am%20copying%20the%20rows%20down.%20I%20have%20attached%20the%20error%20and%20the%20spreadsheet%20again.%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20to%20make%20it%20completely%20fair%20to%20buyers%20and%20to%20be%20truly%20random%20so%20it%20replicates%20drawing%20a%20horse%20'out%20of%20the%20hat'%2C%20I%20think%20the%20number%20of%20buyers%20needs%20to%20be%20divisable%20by%2024%2C%20that%20way%20each%20horse%20is%20allocated%20the%20same%20number%20of%20times.%20If%20you%20could%20fix%20the%20error%20message%20I%20think%20that%20will%20fine%2C%20I%20have%20already%20taken%20up%20alot%20of%20your%20time.%3C%2FP%3E%3CP%3EThanks%20again%20for%20your%20help%2C%20much%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I am running an online event where I will have a list of raffle purchasers. I have seen in previous settings where excel has the functionality to run a program to select a winner randomly. One can see the program scrolling through all the names and then eventually landing on a winner. 

 

Can someone tell me how to run such a program?

22 Replies
Best Response confirmed by allyreckerman (Microsoft)
Solution

@Maree29 

 

With your permission, if I can recommend you, add a file (without sensitive data) to your project.
Explain your plans in relation to this file.
So you can get a solution that is tailored to your needs much faster.
At the same time, it is much easier for someone who wants to help to understand the subject.
A win-win situation for everyone.

Here is a VBA suggestion.

The list of names in column A can be of any length, but must begin in A1.

The second macro builds in the button to trigger the first macro.

Code:
Sub raffle ()
Dim rngBer As Range
Dim lngZ As Long

Randomize

lngZ = Cells (Rows.Count, 1) .End (xlUp) .Row
Set rngBer = Range (Cells (1, 1), Cells (lngZ, 1))
lngZ = CLng (Int (lngZ * Rnd + 1))
Cells (lngZ, 1) .Offset (0, 1) .Value = Cells (lngZ, 1) .Offset (0, 1) .Value + 1

End Sub

'************************************************* *
Sub button ()
With ActiveSheet.Buttons.Add (243, 24, 104.25, 45)
.OnAction = "Raffle"
.Characters.Text = "Start"
End With
End Sub


If you click the button with the right mouse button, you can move it to any position.
 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 
Select random generator from different names Additional information with formula: On this page you will find information on how you can do this with formulas: https://www.extendoffice.com/documents/excel/2768-excel-select-random-names.html I would be happy to know if I could help. Nikolino I know I don't know anything (Socrates)
You are welcome
I was pleased to be able to help you.

Nikolino
I know that I know nothing (Socrates)

@Nikolino 

 

Dear Nikolino, I am afraid the random function is not appropriate. I am not a 'coder' as such I need a formula that will provide the following:

 

If I have 120 Melb Cup Sweep purchasers and I have 24 horses in the race, If all these 24 horses names were put into a hat and each purchasers pulled out a name, I need for the 24 horse names to be randomly allocated to the 120 purchasers. There are 3 placings - 1st, 2nd & 3rd. When the race is run, there should be 5 people with the winning horse, 5 people who get second and 5 people who get third. 

 

So I need a formula that firstly allocates the 24 horses to the purchasers but I need this to replicate as if they were being picked out of hat. So the Random function may not work as it doesn't do this. Plus it keeps changing the random number allocated which is not what I want. 

I thought I might just allocate the horses to the purchasers based on date of purchase starting at Horse 1

See my file attached.

@Maree29 

 

I think you can do that with a circular reference and with iterative calculation turned on (File/Options/Formulas - Enable iterative calculation - I set mine for 200).

 

To generate a new list, you can change the "Reset" drop down to TRUE, then hold down the F9 (calculate) key for a few seconds to randomize the list. Then, change the "Reset" to FALSE and hit/hold the F9 key until each horse appears 5 times (the "Condition Met" cell should change to TRUE).

 

If it were me, once the list is generated, I would copy/paste special value the list to another worksheet just to ensure I didn't accidentally trigger the formulas to recalculate later and cause the list to be re-shuffled.

@JMB17 

I am sorry to bother you again but can you tell me how to do the second part

ie. Reset dropdown. I can't locate it.

 

It might be easier if you could make the change in the file that I sent. And I agree moving the final horse list to a new worksheet is what I would do also.

Regards

If you click on cell B1, you should see a drop down button with True/False options.

@JMB17 Hi Again, you are so clever. I would never have been able to work that out. I got the spreadsheet to output 5 horses for the selected buyers. So if I end up with say 300 buyers do I have to change the settings in formulas. You had put a setting at 200. Will I need to change that depending on the number of buyers I end up with ?

Is there anything else I should know. To ensure I don't mess up your formulas, I will just amend your spreadsheet and copy the buyer names to column A. If then I just update the Horse List values with the actual horse name, once I know it, will that impact the formulas. I am hoping not since it is referencing a cell.

It seems so much easier to cut up the names and put them in a hat. We would be doing that if we weren't living with a pandemic !! Thankyou so much for your help. You are amazing.

@Maree29 

 

Sorry it took me a little while to get back to you.

 

I modified the workbook to use structured tables, which will make the lists easier to resize (Table Tools tab, Resize) and add more entries.

 

Also, I changed the formulas to use structured table references, so you should not have to change the formulas after resizing and changing your customer/horse lists.

 

I added a workbook open macro to turn on iterative calculation to save you a step (just don't save the workbook as an xlsx file as that will strip out the macros).

 

 

@JMB17  Hi again. I got it to work well when the number of buyers was equally divisable by 24. But when it was an odd number such as below I had issues. 

 

I resized the table to 207 sweeps buyers and followed your instructions but for some reason there are some gaps from Sweeps buyers 193 - 207. These final rows remained as false. 

 

Perhaps to make this work, I will need to sell the number of sweeps tickets that will make it divisable by 24 exactly since I am trying to replicate what happens in the real world of 'sweeps'.

You have been a terrific help to me in this so thanks.  When we get closer to the date I will come back to you with how I am going with the number of sales. I have put a deadline of 12 noon on Mon 2nd Nov for me to finalise allocations then I am going to send 24 emails to the buyers advising them of their horse. The race itself takes place the following day on Tues 3rd Nov. Fun hey?

 

@Maree29 

 

Sorry, I assumed all horses would be equally allocated. With 207 sweeps buyers and 24 horses, each horse should be allocated 8 times with 15 horses allocated 9 times?

 

I reworked it to accommodate this remainder. 

@JMB17 

Hi again, I am putting this spreadsheet through the hoops but I think it is great.

 

I extended the number of buyers to 212 sweeps buyers by dragging the last few rows down but when I hold the F9 key it came up with an error to do with a circular reference. I still think the result was correct though.  It might have something to do with how I am copying the rows down. I have attached the error and the spreadsheet again. 

So to make it completely fair to buyers and to be truly random so it replicates drawing a horse 'out of the hat', I think the number of buyers needs to be divisable by 24, that way each horse is allocated the same number of times. If you could fix the error message I think that will fine, I have already taken up alot of your time.

Thanks again for your help, much appreciated.

The file contains circular references by design (otherwise, the random function would never "lock" and just keep recalculating). In order for the formulas to calculate, formula iteration must be enabled (File/Options/Formulas - Enable Iterative Calculation.

When the option is not enabled, you will get the circular reference error. The workbook contains an auto open macro to enable iterative calculation, but it doesn't run before excel attempts to calculate the formulas - so you may get the circular reference error before the auto open macro enables iterative calculation (but should be able to just click through it).

If it doesn't appear to be calculating, double check that option is enabled.

@JMB17 Many thanks for explanation. I have learnt alot during this but I shall leave such work to experts like you. Great job and thanks for being so responsive. I will give you an update when my event is imminent. You may even want to buy a sweeps ticket here https://www.trybooking.com/events/landing?eid=667369&

Cheers !

Maree

@Maree29 

With the permission of everyone involved, here is an additional variant that had to be adapted as required.

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

@Maree29  Help if I added the file....Maree

@JMB17 

Guess what I am back again. I have the sweep worked out but now I need a random generator for the raffle. I thought we would have been able to do this raffle draw 'in person' but it wasn't to be so I will be doing the draw in Excel. I didn't want to play around too much with your Sweep code for fear of messing it up. But could you show me how to do a simple random selection on ticket numbers. In my sample attached I have 62 people who have purchased a raffle ticket. I exported the unique ticket numbers from excel. So I need to randomly draw out 5 names - 5th Prize, 4th Prize, 3rd Prize, 2nd Prize and then 1st Prize. Some people have purchased multiple raffle tickets. I am guessing that part of what you have already provided me will work. 

I promise this is the last time I will bother you. Thankyou again ! Maree

Sorry for the late reply, I've not been on here this week. For a raffle drawing, I would suggest using random.org. They have a random number generator on their home page that is free - number your list 1 to 62 and use that for the min/max for the random number generator.

If the same number cannot win more than once, then scroll down to the "Numbers" section of the home page for the integer set generator, which you can use to generate a set of 5 unique numbers between 1 and 62.

@JMB17 Hi again. Using Random.org was a good idea. Since I am trying to replicate the drawing of winners for 5 prizes, I used the Integer generator using 5 sets (5 draws) with one unique integer. I think this replicates how a raffle draw would work the best. Probably even better because often when you do raffle draws a person can win more than once. Could you confirm my thinking is correct. Very useful having someone to bounce things off. 

 

And with the horse program, I am doing 4 sets of 24 horses (96 tickets) as this is how a sweep would work in the physical world. 

Once again, many many thanks  for your help. I have learnt so much...Maree