Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / August 2007

Tip: Looking for answers? Try searching our database.

User-defined Function With Varible Number of Inputs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonas - 31 Aug 2007 19:45 GMT
I am trying to create a VBA function that will take a variable number
of inputs.  Is there a way to declare a variable number of inputs for
a function?  I have found that if I don't use the total number of
inputs declared, I will get #Value.  My thought is that a loop could
be created to count the number of inputs used in the statement in
Excel =myfunction(input1, input2, input3.....).

This is probably a simple problem but I haven't been able to find the
solution yet.
- - 31 Aug 2007 20:05 GMT
A ParamArray does that.

Sub fsdadfs()
   MsgBox UDFTest("a", "b", "c")
End Sub

Function UDFTest(ParamArray args() As Variant) As String
   Dim s As String
   Dim i As Integer
   For i = LBound(args) To UBound(args)
       s = s & args(i) & vbLf
   Next
   UDFTest = s
End Function

>I am trying to create a VBA function that will take a variable number
> of inputs.  Is there a way to declare a variable number of inputs for
[quoted text clipped - 5 lines]
> This is probably a simple problem but I haven't been able to find the
> solution yet.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.