#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Array

I am generating random numbers through the following code:

Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range(RanRowStart), 1,
NumDays, Distribution, , Param1, Param2

In this case NumDays number of random numbers are generated and pasted to
cell starting from RanRowStart. Suppose if NumDays is 15 and RanRowStart is
cell o25, then excel is writing the 15 random numbers generated to cell o25
and downwards.

I want to create an array and transfer the random numbers there.
i have used following code:
Dim ArrayRnd () as Double
Re Dim ArrayRnd as (NumDays,1)

Application.Run "ATPVBAEN.XLA!Random", ArrRand(1:NumDays), 1, n,
Distribution, , Param1, Param2

I want to give the array the random number generated. The code above is not
working. request help
regards
pradip
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Array

I would think that the Random function is designed to expect a range
argument and it might not know what to do if it gets an array instead. Can
you not populate the array from the sheet dump?

--
Jim
"Pradip Jain" wrote in message
...
|I am generating random numbers through the following code:
|
| Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range(RanRowStart), 1,
| NumDays, Distribution, , Param1, Param2
|
| In this case NumDays number of random numbers are generated and pasted to
| cell starting from RanRowStart. Suppose if NumDays is 15 and RanRowStart
is
| cell o25, then excel is writing the 15 random numbers generated to cell
o25
| and downwards.
|
| I want to create an array and transfer the random numbers there.
| i have used following code:
| Dim ArrayRnd () as Double
| Re Dim ArrayRnd as (NumDays,1)
|
| Application.Run "ATPVBAEN.XLA!Random", ArrRand(1:NumDays), 1, n,
| Distribution, , Param1, Param2
|
| I want to give the array the random number generated. The code above is
not
| working. request help
| regards
| pradip


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Array

It looks like you have inserted a space into your "ReDim" command, making it
"Re Dim". Try removing the space and see if it works then. Also, the Random
function will need some way to know the destination is now an array, instead
of a range. If there is no option to do this, you will have to write code to
copy the values from the range into your array.

"Pradip Jain" wrote:

I am generating random numbers through the following code:

Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range(RanRowStart), 1,
NumDays, Distribution, , Param1, Param2

In this case NumDays number of random numbers are generated and pasted to
cell starting from RanRowStart. Suppose if NumDays is 15 and RanRowStart is
cell o25, then excel is writing the 15 random numbers generated to cell o25
and downwards.

I want to create an array and transfer the random numbers there.
i have used following code:
Dim ArrayRnd () as Double
Re Dim ArrayRnd as (NumDays,1)

Application.Run "ATPVBAEN.XLA!Random", ArrRand(1:NumDays), 1, n,
Distribution, , Param1, Param2

I want to give the array the random number generated. The code above is not
working. request help
regards
pradip

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Array

If the random numbers are pasted to the excel sheet and then the array is
populated from the sheet, the speed is reduced considerably. i need to do a
large number of simulations to get a result, hence need to do all
calculations in memory space, that is array. writing to excel and reading
from it would slow the process considerably.
Regards
Pradip

"Jim Rech" wrote:

I would think that the Random function is designed to expect a range
argument and it might not know what to do if it gets an array instead. Can
you not populate the array from the sheet dump?

--
Jim
"Pradip Jain" wrote in message
...
|I am generating random numbers through the following code:
|
| Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range(RanRowStart), 1,
| NumDays, Distribution, , Param1, Param2
|
| In this case NumDays number of random numbers are generated and pasted to
| cell starting from RanRowStart. Suppose if NumDays is 15 and RanRowStart
is
| cell o25, then excel is writing the 15 random numbers generated to cell
o25
| and downwards.
|
| I want to create an array and transfer the random numbers there.
| i have used following code:
| Dim ArrayRnd () as Double
| Re Dim ArrayRnd as (NumDays,1)
|
| Application.Run "ATPVBAEN.XLA!Random", ArrRand(1:NumDays), 1, n,
| Distribution, , Param1, Param2
|
| I want to give the array the random number generated. The code above is
not
| working. request help
| regards
| pradip



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Array

Apologies, it is ReDim only. The space was a typo

"LabElf" wrote:

It looks like you have inserted a space into your "ReDim" command, making it
"Re Dim". Try removing the space and see if it works then. Also, the Random
function will need some way to know the destination is now an array, instead
of a range. If there is no option to do this, you will have to write code to
copy the values from the range into your array.

"Pradip Jain" wrote:

I am generating random numbers through the following code:

Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range(RanRowStart), 1,
NumDays, Distribution, , Param1, Param2

In this case NumDays number of random numbers are generated and pasted to
cell starting from RanRowStart. Suppose if NumDays is 15 and RanRowStart is
cell o25, then excel is writing the 15 random numbers generated to cell o25
and downwards.

I want to create an array and transfer the random numbers there.
i have used following code:
Dim ArrayRnd () as Double
Re Dim ArrayRnd as (NumDays,1)

Application.Run "ATPVBAEN.XLA!Random", ArrRand(1:NumDays), 1, n,
Distribution, , Param1, Param2

I want to give the array the random number generated. The code above is not
working. request help
regards
pradip

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
Complex conditional summing - array COUNT works, array SUM gives#VALUE fatcatfan Excel Worksheet Functions 4 November 18th 09 06:41 PM
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Assigning 10x1 array to 2nd collumn of 10x3 array Myrna Larson Excel Programming 0 July 29th 04 11:57 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 10:42 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"