Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I pasted the macro I have below. I want to add to it so that it will
randomly select 20 of the cells from the range E2:E159 to copy and paste those contents starting in cell B2. Is this possible? Random Copy Paste() Range("E2:E159").Select Selection.Copy Range("B2").Select ActiveSheet.Paste End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
Sub randomSelect() Dim MyValue For i = 2 To 21 MyValue = Int((158 * Rnd) + 2) 'Cells(i, 3) = MyValue Range("E" & MyValue).Copy Destination:=Range("B" & i) Next End Sub "TGalin" wrote: I pasted the macro I have below. I want to add to it so that it will randomly select 20 of the cells from the range E2:E159 to copy and paste those contents starting in cell B2. Is this possible? Random Copy Paste() Range("E2:E159").Select Selection.Copy Range("B2").Select ActiveSheet.Paste End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To cool! Thank you. It works great!
"Sheeloo" wrote: Try Sub randomSelect() Dim MyValue For i = 2 To 21 MyValue = Int((158 * Rnd) + 2) 'Cells(i, 3) = MyValue Range("E" & MyValue).Copy Destination:=Range("B" & i) Next End Sub "TGalin" wrote: I pasted the macro I have below. I want to add to it so that it will randomly select 20 of the cells from the range E2:E159 to copy and paste those contents starting in cell B2. Is this possible? Random Copy Paste() Range("E2:E159").Select Selection.Copy Range("B2").Select ActiveSheet.Paste End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are most welcome.
I hope you realize that you may get the same value more than once... as the numbers generated are not guaranteed to be unique. Do get unique numbers you need to generate the numbers and then rank them with unqiue ranks... a fairly complicated exercise. "TGalin" wrote: To cool! Thank you. It works great! "Sheeloo" wrote: Try Sub randomSelect() Dim MyValue For i = 2 To 21 MyValue = Int((158 * Rnd) + 2) 'Cells(i, 3) = MyValue Range("E" & MyValue).Copy Destination:=Range("B" & i) Next End Sub "TGalin" wrote: I pasted the macro I have below. I want to add to it so that it will randomly select 20 of the cells from the range E2:E159 to copy and paste those contents starting in cell B2. Is this possible? Random Copy Paste() Range("E2:E159").Select Selection.Copy Range("B2").Select ActiveSheet.Paste End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select Random rows and paste it in a different sheet. | Excel Programming | |||
Automating copy/paste/paste special when row references change | Excel Programming | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) | |||
Copy and Paste macro needs to paste to a changing cell reference | Excel Programming | |||
Random Copy and Paste | Excel Programming |