View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_2_] Nigel[_2_] is offline
external usenet poster
 
Posts: 735
Default 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