Random number and indirect problem

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,927
Office Version
  1. 365
Platform
  1. Windows
I have this data...

Excel Workbook
CDE
1LastFirst
2
3RaferAlstonc
4DaliborBagaricc
5SpiderBennettc
6UweBlabc
7OrbieBowlingc
8OmriCasspic
9KeonClarkc
10VonteegoCummingsc
11RadisavCurcicc
12RastkoCvetkovicc
13PredragDrobnjakc
14PervisEllisonc
15KyryloFesenkoc
16WyndolGrayc
17LitterialGreenc
18SihugoGreenc
19TaureanGreenc
20JrueHolidayc
21DarHutchinsc
22BoagJohnsonc
23AskiaJonesc
24ArvestaKellyc
25GooKennedyc
26BuzzKnoblauchc
27ArvydasMacijauskasc
28HannoMottolac
29EmekaOkaforc
30JanneroPargoc
31ZarkoPaspaljc
32SquintPharesc
33VitalyPotapenkoc
34ZeljkoRebracac
35EfthimiosRentziasc
36PredragSavovicc
37AnsuSesayc
38PurvisShortc
39UrosSlokarc
40BelloSnyderc
41VassilisSpanoulisc
42AwveeStoreyc
43SunYuec
44ChelsoTamagnoc
45RatkoVardac
46SlavkoVranesc
47StojkoVrankovicc
48DelonteWestc
49QyntelWoodsc
50WarrenAjaxd
51GaryAlcornd
52SteveAlfordd
53PeterAlumad
54AshrafAmayad
55RalphAmsdend
56BobAndereggd
57StaceyArceneauxd
58GilbertArenasd
59PaulArizind
60BobArnzend
61StanArnzend
62VincentAskewd
63AnthonyAventd
64CedricBalld
65MikeBantomd
66JackBurmasterd
67MikeBytzurad
68PeteChilcuttd
69DeSaganaDiopd
70FredDiuted
71KeyonDoolingd
72CraigEhlod
73MikeErteld
74JackEskridged
75KenExeld
76AlFerrarid
77RonFilipekd
78ChrisGatlingd
79GordanGiricekd
80GeorgeGlamackd
81MarcinGortatd
82LeoGottliebd
83NormGrekind
84WaltHazzardd
85JohnHummerd
86TonyJarosd
87JonasJerebkod
88BillJeskod
89SplinterJohnsond
90GeorgeKaftand
91LarryKenond
92BudKoperd
93TomKozelkod
94VicKrafftd
95LesKublicd
96TrajanLangdond
97HalLeard
98FatLeverd
99MarcusLibertyd
100MarkMacond
101TedManakasd
102KennedyMcIntoshd
103DonMeineked
104SteveMixd
105DyronNixd
106CharlesOakleyd
107AndyPankod
108PetePascod
109DesmondPenigard
110BillPerigod
111JohanPetrod
112JoelPrzybillad
113DaveQuabiusd
114RajonRondod
115BrianScalabrined
116GlenSelbod
117WalterSharped
118JohnShumated
119ZekeSinicolad
120JoeSotakd
121GinoSovrand
122JimSpanarkeld
123ArtSpoelstrad
124BuckSydnord
125BrettSzabod
126DraganTarlacd
127ImeUdokad
128NickExeld
129GundarsVetrad
130WangZhizhid
131TonyWindisd
132HarthorneWingod
133EddieWisbard
134TonyZenod
135GeorgeZidekd
Sheet3


I am trying to write a formula which will randomly retrieve one of these names, and whether it brings up the first name or the last name is based on the value in column E (if the value is C then column C, Value of d then column D.

I am trying to use a combination of the indirect function with the int(rand()*133)+3 combo in order to get my random number. The way I am writing it as if(int(rand()*133)+3="c",indirect("E"&int(rand()*133)+3... blah blah blah, will return two different random numbers and I need them to be the same number. Any thoughts?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You could put in each cell of column F the formula =RAND(), then have the formula find the largest of those. That number will move each time you recalculate, but for any given run through the formula the same cell will be the largest. Then instead of INDIRECT you could use INDEX and MATCH.
 
Upvote 0
Put the RAND() function in a cell. Then reference that cell in your formula. This way the value in the cell will change with each recalculation but your formula will refer the same value for each recalculation.

I have this data...

Excel Workbook
CDE
1LastFirst*
2***
3RaferAlstonc
4DaliborBagaricc
5SpiderBennettc
6UweBlabc
7OrbieBowlingc
8OmriCasspic
9KeonClarkc
10VonteegoCummingsc
11RadisavCurcicc
12RastkoCvetkovicc
13PredragDrobnjakc
14PervisEllisonc
15KyryloFesenkoc
16WyndolGrayc
17LitterialGreenc
18SihugoGreenc
19TaureanGreenc
20JrueHolidayc
21DarHutchinsc
22BoagJohnsonc
23AskiaJonesc
24ArvestaKellyc
25GooKennedyc
26BuzzKnoblauchc
27ArvydasMacijauskasc
28HannoMottolac
29EmekaOkaforc
30JanneroPargoc
31ZarkoPaspaljc
32SquintPharesc
33VitalyPotapenkoc
34ZeljkoRebracac
35EfthimiosRentziasc
36PredragSavovicc
37AnsuSesayc
38PurvisShortc
39UrosSlokarc
40BelloSnyderc
41VassilisSpanoulisc
42AwveeStoreyc
43SunYuec
44ChelsoTamagnoc
45RatkoVardac
46SlavkoVranesc
47StojkoVrankovicc
48DelonteWestc
49QyntelWoodsc
50WarrenAjaxd
51GaryAlcornd
52SteveAlfordd
53PeterAlumad
54AshrafAmayad
55RalphAmsdend
56BobAndereggd
57StaceyArceneauxd
58GilbertArenasd
59PaulArizind
60BobArnzend
61StanArnzend
62VincentAskewd
63AnthonyAventd
64CedricBalld
65MikeBantomd
66JackBurmasterd
67MikeBytzurad
68PeteChilcuttd
69DeSaganaDiopd
70FredDiuted
71KeyonDoolingd
72CraigEhlod
73MikeErteld
74JackEskridged
75KenExeld
76AlFerrarid
77RonFilipekd
78ChrisGatlingd
79GordanGiricekd
80GeorgeGlamackd
81MarcinGortatd
82LeoGottliebd
83NormGrekind
84WaltHazzardd
85JohnHummerd
86TonyJarosd
87JonasJerebkod
88BillJeskod
89SplinterJohnsond
90GeorgeKaftand
91LarryKenond
92BudKoperd
93TomKozelkod
94VicKrafftd
95LesKublicd
96TrajanLangdond
97HalLeard
98FatLeverd
99MarcusLibertyd
100MarkMacond
101TedManakasd
102KennedyMcIntoshd
103DonMeineked
104SteveMixd
105DyronNixd
106CharlesOakleyd
107AndyPankod
108PetePascod
109DesmondPenigard
110BillPerigod
111JohanPetrod
112JoelPrzybillad
113DaveQuabiusd
114RajonRondod
115BrianScalabrined
116GlenSelbod
117WalterSharped
118JohnShumated
119ZekeSinicolad
120JoeSotakd
121GinoSovrand
122JimSpanarkeld
123ArtSpoelstrad
124BuckSydnord
125BrettSzabod
126DraganTarlacd
127ImeUdokad
128NickExeld
129GundarsVetrad
130WangZhizhid
131TonyWindisd
132HarthorneWingod
133EddieWisbard
134TonyZenod
135GeorgeZidekd
Sheet3


I am trying to write a formula which will randomly retrieve one of these names, and whether it brings up the first name or the last name is based on the value in column E (if the value is C then column C, Value of d then column D.

I am trying to use a combination of the indirect function with the int(rand()*133)+3 combo in order to get my random number. The way I am writing it as if(int(rand()*133)+3="c",indirect("E"&int(rand()*133)+3... blah blah blah, will return two different random numbers and I need them to be the same number. Any thoughts?
 
Upvote 0
Edit: I notice Tushar has posted a similar suggestion while I was composing mine. never-the-less ...

... or maybe just use a single cell to get the random number then index. Note that RANDBETWEEN requires Analysis ToolPak to be installed and activated. If not you could use a form of RAND() as you were already using to generate the number in G1.

Excel Workbook
CDEFG
1LastFirstRand No5
2NameOrbie
3RaferAlstonc
4DaliborBagaricc
5SpiderBennettc
6UweBlabc
7OrbieBowlingc
8OmriCasspic
9KeonClarkc
10VonteegoCummingsc
11RadisavCurcicc
Rand Name
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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