Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Nick, that was it. I changed temp to a variant and all is well.
NickHK wrote: It not the input arguments that are the problem, it the function's return value. Or rather it's the variables you are attempting to assign to the return value. Will you function return an array of integers or (an array in) a variant or an array of variant ? Dim temp() As Integer Public Function RandomNumbers(<arguments) As Variant Dim randomNums(), unsortedRandoms(), unsortedExtras() NickHK wrote in message oups.com... Hehe, I didnt think you would want to look at that mess. The problem is just that I get a runtime error 13 type mismatch on the RandomNumbers function call. It doesnt seem to like the firstNumber(q) argument for the function. The function is defined to accept integers, so I am thinking that its not recognizing this number in the array as an integer. Is the application.inputbox statement correct to put an integer in the array? Can I not call the function with the array like it is? Thanks again. Alan Beban wrote: Now that I asked for it I don't know that I want it. Is the problem simply that the function you posted doesn't perform any function? In the form in which you posted it it doesn't. Alan Beban wrote: Thanks for the reply. Here is the whole subroutine. Sub randomgen() 'Declare temporary arrays Dim randomNums(), unsortedRandoms(), unsortedExtras() Dim randomWeights() As Integer Dim extraWeights() As Integer Dim temp() As Integer Dim lastNumber() As Integer Dim firstNumber() As Integer 'randoms will hold the sorted random sample numbers 'extras will hold the sorted substitutes Dim extras(), randoms() 'declare counters Dim a, b, i, j, k, m, p, q, currentRandom, totalRange, counterR, counterE As Integer ----------- SNIP ------------------------ counterR = 0 counterE = 0 For q = 0 To Cells(4, 2) - 1 'get random numbers for current range Cells(5, 2) = extraWeights(q) temp = RandomNumbers(lastNumber(q), firstNumber(q), (randomWeights(q) + extraWeights(q))) 'put randoms in unsorted randoms ---------- SNIP ------------------------ 'Only one range Else 'Call random number function and put result in randomNums randomNums = RandomNumbers(Worksheets("temp data").Cells(1, 2), Worksheets("temp data").Cells(1, 1), (Cells(2, 2) + Cells(3, 2)) * 5) ------------- SNIP ------------- Public Function RandomNumbers(Upper As Integer, _ Optional Lower As Integer = 1, _ Optional HowMany As Integer = 1, _ Optional Unique As Boolean = True) As Variant end function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I use and indexed value as the name of an array for vlooku | Excel Worksheet Functions | |||
Passing array from Access to Excel function | Excel Programming | |||
Sum from an indexed array/table | Excel Discussion (Misc queries) | |||
Passing array of strings from DLL function to VBA | Excel Programming | |||
Passing array to a function | Excel Programming |