![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: Australia
Posts: 25
|
Does anyone know how to generate up to 6 random numbers from a series?
Would appreciate some help. Thank you |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,805
|
Quote:
If your numbers are range A1:A30 for example, then put in an empty cell (B1) the formula: =INDEX($A$1:$A$30,RANDBETWEEN(1,30)) Drag it down 6 rows and you'll get 6 random numbers from your series. You can also use F9 to get another new 6 numbers. Eli |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
Hello
Dave Hawley wrote a UDF called Randlotto take a look http://www.mrexcel.com/board/viewtop...rum=2&start=20 Hope that helps
__________________
Best Regards Andreas
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,065
|
Sub Jack() ' Lucky_Lottery_Numbers
'I designed this as i felt like it really & just to learn a bit. 'The trick was not to random produce numbers, but to FIND numbers selected at rand 'All in all the type of code can be used for many diff ideas, the search system 'is cool and will do the business, the loop will give a list and custom as desired 'As with all my work, i could not care if you use the codes or hack, bastardise it, but 'i do dedicate all my work to friends. '(Please.. If you use my codes... 'Give a kind thought to them, they all me the world to me) ' Dedicated to ......... (ive delete this bit people how know me well will know – ‘ I dedicate to my lost friends – I miss so much normally ‘ yes I do name them …. Take care friends! On Error GoTo Z Application.ScreenUpdating = False Dim Lottery_Numbers(6) Range("B4:O6,E7:K7").Select With Selection .Borders(xlLeft).LineStyle = xlNone .Borders(xlRight).LineStyle = xlNone .Borders(xlTop).LineStyle = xlNone .Borders(xlBottom).LineStyle = xlNone .BorderAround LineStyle:=xlNone .Interior.ColorIndex = xlNone End With Range("A1").Select For Different_Number = 1 To 6 Choose: Lottery_Numbers(Different_Numbers) = Int((49) * Rnd + 1) Cells.Find(What:=Lottery_Numbers(Different_Numbers)).Activate Selection.BorderAround Weight:=xlThin, ColorIndex:=xlAutomatic If Selection.Interior.ColorIndex = 35 Then GoTo Choose With Selection.Interior .ColorIndex = 35 .Pattern = xlSolid .PatternColorIndex = xlAutomatic End With Next Different_Number Z: End Sub MARKER Lotto
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Board Regular
Join Date: Feb 2002
Posts: 3,065
|
You will need to have cells with number exactley in these cells or edit the range in the code see post above.
To see the formula in the cells just click on the cells hyperlink The above image was automatically generated by [HtmlMaker V1.20] If you want this code, click here and Colo will email the file to you. This code was graciously allowed to be modified: by Ivan F Moala All credit to Colo _________________ If you can help a guy in trouble - If you can sort that nagging problem - Pease try, at home, at work or on a message board. Others help you! So PLEASE help if you can - If only the once. Thank you - Rdgs ====== [ This Message was edited by: Jack in the UK on 2002-05-16 06:44 ] |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|