Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlimited number of variables?
Sometimes you never know how many variables you would be needing to gather a
data. For example, =SUM(Variable-1, Variable-2, ...., Variable-n) How to declare the same in this regard? Any sample shall be appreciated. -- Thanx in advance, Best Regards, Faraz |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlimited number of variables?
Use an array. In the below example variable arrTemp is redimensioned at
runtime to store values 1 to 1000..at position 1 to 1000... http://msdn.microsoft.com/en-us/libr...s2(VS.71).aspx Dim arrTemp As Variant ReDim arrTemp(0) For intCount = 1 To 1000 ReDim Preserve arrTemp(intCount) arrTemp(intCount) = intCount Next -- Jacob "Faraz A. Qureshi" wrote: Sometimes you never know how many variables you would be needing to gather a data. For example, =SUM(Variable-1, Variable-2, ...., Variable-n) How to declare the same in this regard? Any sample shall be appreciated. -- Thanx in advance, Best Regards, Faraz |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlimited number of variables?
Sorry Jacob but the picture's still unclear. Buddy, can you please simply
design a simple sum type of a function like: =XSUM(Variable-1, Variable-2, ...., Variable-n) With a ReDim statement used? Thanx again, Best Regards, Faraz "Jacob Skaria" wrote: Use an array. In the below example variable arrTemp is redimensioned at runtime to store values 1 to 1000..at position 1 to 1000... http://msdn.microsoft.com/en-us/libr...s2(VS.71).aspx Dim arrTemp As Variant ReDim arrTemp(0) For intCount = 1 To 1000 ReDim Preserve arrTemp(intCount) arrTemp(intCount) = intCount Next -- Jacob "Faraz A. Qureshi" wrote: Sometimes you never know how many variables you would be needing to gather a data. For example, =SUM(Variable-1, Variable-2, ...., Variable-n) How to declare the same in this regard? Any sample shall be appreciated. -- Thanx in advance, Best Regards, Faraz |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlimited number of variables?
Sometimes you never know how many variables you would be needing...
Hi. You may be looking for the ParamArray option. Example: Function MySum(ParamArray v() As Variant) MySum = WorksheetFunction.Sum(v) End Function Sub TestIt() Debug.Print MySum(1, 2, 3) Debug.Print MySum(1, 2, 3, 4, 5, 6) End Sub = = = = = = = = = = HTH :) Dana DeLouis On 12/26/2009 12:56 AM, Faraz A. Qureshi wrote: Sorry Jacob but the picture's still unclear. Buddy, can you please simply design a simple sum type of a function like: =XSUM(Variable-1, Variable-2, ...., Variable-n) With a ReDim statement used? Thanx again, Best Regards, Faraz "Jacob Skaria" wrote: Use an array. In the below example variable arrTemp is redimensioned at runtime to store values 1 to 1000..at position 1 to 1000... http://msdn.microsoft.com/en-us/libr...s2(VS.71).aspx Dim arrTemp As Variant ReDim arrTemp(0) For intCount = 1 To 1000 ReDim Preserve arrTemp(intCount) arrTemp(intCount) = intCount Next -- Jacob "Faraz A. Qureshi" wrote: Sometimes you never know how many variables you would be needing to gather a data. For example, =SUM(Variable-1, Variable-2, ...., Variable-n) How to declare the same in this regard? Any sample shall be appreciated. -- Thanx in advance, Best Regards, Faraz |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unlimited # of arguments in a UDF | Excel Discussion (Misc queries) | |||
If Statement Unlimited In Excel | Excel Discussion (Misc queries) | |||
how can i make a cell unlimited | Excel Discussion (Misc queries) | |||
unlimited | New Users to Excel | |||
Excel should have an unlimited number of columns available. | Excel Worksheet Functions |