Ask questions via twitter! Message any question to @answers on twitter. We'll publish the question and send you a reply each time there's a new answer.
Next Question

Answered Question

 
M$2 September 01, 2009 08:10 PM

Excel: create a selection of random cells

I have an excel sheet with one column and ~10,000 rows. I wanted to select 100 random values from that column and either 1) create a new column with those values or 2) create a new excel sheet with those values.

Thanks!
Interesting Question?  Yes (0)   No (0)   
RSS
 
 

Best Answer  Chosen by Asker

 
September 01, 2009 09:02 PM
Try this:
Copy the following formula into 100 cells on the current worksheet (or add the worksheet name to the cell references and add it to a different worksheet):

=HLOOKUP($A$1,$A$1:$A$10000,RANDBETWEEN(1,10000),FALSE)

In my example, I'm assuming you have EXACTLY 10,000 rows - if it is more or less just change the "A10000" and "10000" in my formula above to the number of rows in your list.

In each cell this is effectively keying on your first cell and then moving down a "Random" number of rows (between 1 - the first cell - and 10000 - the last cell). It may not be the prettiest solution, but it looks like it will work.
Asker's Rating:
• Love it - great, thanks.


Helpful Answer?  (0)   (0)    Tip mrcal for this answer
Permalink | Report
   Reply  
 
 

Other Answers (2)

Sort By
 
September 01, 2009 09:30 PM
If you like a vba aproach you can use this code

'Create the Random function
Function RandCell(Rg As Range) As Range
Set RandCell = Rg.Cells(Int(Rnd * Rg.Cells.Count) + 1)
End Function

'And Use it As you wish

Sub RandCellTest()
Dim Counter As Long
Dim TargetRg As Range
Set TargetRg = Range("A1:A10000") ' The range of values you have
Dim Cell As Range
For Counter = 1 To 100
Set Cell = RandCell(TargetRg)
Cell.Value = Cell.Value + 1
Cells(Counter, 2).Value = Cell.Value
Next

End Sub

Tags: vba, random, excel, select

Helpful Answer?  (0)   (0)    Tip planetexcel for this answer
Permalink | Report
   Reply  
 
 
 
September 04, 2009 09:35 AM
if column with values is named A, copy the rule =IF(RAND()<100/10000;A1;0) to each row in some other column, and you will have ca. 100 randomly picked values out of 10 000 values.

Helpful Answer?  (0)   (0)    Tip mimowolny for this answer
Permalink | Report
   Reply  
 
 

Answer this Question

How tips and payments work

This question has already been resolved. You may add an answer to it but you will not be eligible to win best answer or any associated tips.

Related Questions

No questions found.

Ask a Question


140 characters left
Top of Page
Buy Mahalo Dollars with Credit Card or PayPal

Top Members

This Week All Time
  • cfinke
    cfinke
    2nd Degree Black Belt
    26761 Points
    M$29.75 Earned
  • bunnyphuph...
    bunnyphuph...
    2nd Degree Black Belt
    20771 Points
    M$756.54 Earned
  • thisjustme
    thisjustme
    Green Belt
    1145 Points
    M$76.05 Earned
   See All
 

Most Popular Tags

mahalo(1758)
music(493)
iphone(481)
google(381)
online(345)
food(336)
beer(284)
money(281)
movies(276)
apple(257)
aotd(235)
health(227)
free(225)
video(221)
dog(210)
   See All
 

Categories

Welcome New Members


 
 
Mahalo Dollars are the currency of Mahalo Answers.

Each Mahalo Dollar costs $1.

Once you earn more than 40 Mahalo Dollars, you can request to be paid via PayPal. Each Mahalo Dollar is currently worth $0.75 when paid out via PayPal. Learn More

 
 

Please log in to use this function.