ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Entries Help (https://www.excelbanter.com/excel-programming/414043-random-entries-help.html)

James8309

Random Entries Help
 
Hi, Everyone

I am trying to create a macro pull random data from my data sheet 10
at a time.
i.e.

1. I have two sheets - Sheets("A") and Sheets("Data")

2. Sheets("A") is blank sheet where Sheets("Data") has number&alphabet
combined code from Range("A1:AM65536")

3. How do I macro to pick 10 of any cell's value in Sheets("data") and
place in sheets("A").Range("A1:A10") ?

i.e Each time I run macro it will select 10 values from data sheet
randomly and places it in sheet A from Cell A1.

Thank you for your help in advance


Nigel[_2_]

Random Entries Help
 
Calculate random column 1-39 (A-AM) and random row 1-65536 transfer value
from Data to Sheet A
Optional last 2 lines in loop to display actual col and row used, in SheetA
columns B & C.

Sub RandomFill()
Dim rRow As Single, rCol As Single, iRow As Integer
Randomize
For iRow = 1 To 10
rCol = Int((39 * Rnd) + 1)
rRow = Int((65536 * Rnd) + 1)
Sheets("A").Cells(iRow, "A") = Sheets("Data").Cells(rRow, rCol)
'Sheets("A").Cells(iRow, "B") = rCol
'Sheets("A").Cells(iRow, "C") = rRow
Next

End Sub

--

Regards,
Nigel




"James8309" wrote in message
...
Hi, Everyone

I am trying to create a macro pull random data from my data sheet 10
at a time.
i.e.

1. I have two sheets - Sheets("A") and Sheets("Data")

2. Sheets("A") is blank sheet where Sheets("Data") has number&alphabet
combined code from Range("A1:AM65536")

3. How do I macro to pick 10 of any cell's value in Sheets("data") and
place in sheets("A").Range("A1:A10") ?

i.e Each time I run macro it will select 10 values from data sheet
randomly and places it in sheet A from Cell A1.

Thank you for your help in advance




All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com