Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default 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
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
Unlimited # of arguments in a UDF FARAZ QURESHI Excel Discussion (Misc queries) 1 April 12th 09 10:06 AM
If Statement Unlimited In Excel SyntaxError Excel Discussion (Misc queries) 8 February 16th 07 11:16 PM
how can i make a cell unlimited Moh Excel Discussion (Misc queries) 16 September 25th 06 10:39 PM
unlimited Moh New Users to Excel 1 September 25th 06 02:04 AM
Excel should have an unlimited number of columns available. jkp Excel Worksheet Functions 8 December 13th 05 06:04 PM


All times are GMT +1. The time now is 10:37 AM.

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"