AdZ9
Member
Registered: 14th Apr 06
User status: Offline
|
Yo
Basically I need someone that knows a little bit on Excel as i'm guessing this is quite easy for someone who knows how!
I have two lists of names, both lists have 26 names in it.
Basically I want to put both lists into excel, and have a button or another cell that somehow random picks one name from one list and one from another and puts them together in a cell to create a new name so to speak.
Does anyone have an idea on how I can do it, or the code I use to get it to work?
Cheers,
Adam
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
Are you storing both forenames and surnames in these two lists? How do you want the final data to be? eg: if it picks 'Frank' and 'Bob', do you want to be 'Frank Bob'?
Would you want the data placed in another cell or could it just alert you (using a message box etc)?
Eitherway you could do it using VB Macro's, would be fairly simple
edit - http://it.toolbox.com/wiki/index.php/Basics_of_Excel_VBA:_Cell_Navigation , lists the standard VBA to select cells and get the data (looks at 'Using Variables').
Something like below will grab the data -
Range("A" + Int ((26 - 1 + 1) * Rnd + 1)).Select
strName1 = ActiveCell.Value
Range("B" + Int ((26 - 1 + 1) * Rnd + 1)).Select
strName2 = ActiveCell.Value
Then you can dump the data to a message box (ie: popup alert box) like so -
MsgBox(strName1 & chr(13) & strName2)
All of that on a button should churn something out (all of the top of my head), although you might have to open the workbook and sheet first.
[Edited on 24-06-2009 by Dom]
|
blebo
Member
Registered: 18th Apr 02
User status: Offline
|
In coluum A list numbers 1 - 26
In coluum B all Forenames in a lst
In coluum C list numbers 1 - 26
In coluum D all Forenames in a lst
Then in any other cell
Paste =CONCATENATE(VLOOKUP(ROUND(RAND()*6,0),A:B,2,0)," ",(VLOOKUP(ROUND(RAND()*6,0),C,2,0)))
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
You could also use CHOOSE()
=CHOOSE(RANDBETWEEN(1,26),"Alf", "Bob", "Carl", "Dave" ... "Zak")
|
|