Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Random Copy Paste

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Random Copy Paste

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Random Copy Paste

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Random Copy Paste

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Random rows and paste it in a different sheet. Heera Excel Programming 0 January 28th 09 07:26 PM
Automating copy/paste/paste special when row references change Carl LaFong Excel Programming 4 October 8th 07 06:10 AM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Random Copy and Paste Jason Excel Programming 2 September 10th 04 09:27 AM


All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"