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

Hello,
I am new to VBA scripting, I have a problem that in an excel sheet i
have got a large number of cusips in a column. I want to pull cusips
randomly from that list. I am currently doing a RANDBETWEEN after
calculating the number of rows and getting to the row no that comes in
the random number.the problem is that everday the no of rows keep on
changing. I want to write a macro for the same .
Thanks in advance.
Nishant

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Random numbers generation

Dim rng as Range, rng1 as Range, num as Long
set rng = Range(cells(2,5),cells(2,5).End(xldown))
num = int(rnd()*rng.count+1)
set rng1 = rng(num)
msgbox rng1.value

--
Regards,
Tom Ogilvy

"Nishant" wrote in message
oups.com...
Hello,
I am new to VBA scripting, I have a problem that in an excel sheet i
have got a large number of cusips in a column. I want to pull cusips
randomly from that list. I am currently doing a RANDBETWEEN after
calculating the number of rows and getting to the row no that comes in
the random number.the problem is that everday the no of rows keep on
changing. I want to write a macro for the same .
Thanks in advance.
Nishant



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Random numbers generation



hi,
I tried running the script but got the error message

Sub Macro1()

Macro1 Macro

Dim rng as Range, rng1 as Range, num as Long
set rng = Range(cells(2,5),cells(2,5).End(xldown))
num = int(rnd()*rng.count+1)
set rng1 = rng(num)
msgbox rng1.value

End Sub

*** Sent via Developersdex http://www.developersdex.com ***
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
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
Generation of random numbers and sum of those with a condition ramana Excel Worksheet Functions 11 October 5th 05 05:01 AM
Random numbers generation with conditions. ramana Excel Worksheet Functions 3 October 3rd 05 05:06 AM
Random Name Generation pkbro Excel Worksheet Functions 1 June 21st 05 02:03 AM
Random Generation lordofthe9 Excel Programming 5 May 5th 05 03:58 PM


All times are GMT +1. The time now is 05:32 PM.

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

About Us

"It's about Microsoft Excel"