Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function Declarations !!!!!!!!!!!!!!!!!!!!!!
How do you declare a variable as OPTIONAL in a UDF. I have a function that I
use in one of my macros but I would like to declare at least one of the variables as an optional variable. I am not sure how to do that. Any ideas? Thanks Ayo |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function Declarations !!!!!!!!!!!!!!!!!!!!!!
On Wed, 14 Apr 2010 12:02:01 -0700, Ayo
wrote: How do you declare a variable as OPTIONAL in a UDF. I have a function that I use in one of my macros but I would like to declare at least one of the variables as an optional variable. I am not sure how to do that. Any ideas? Thanks Ayo Have a look under "Using a Variable Number Of Parameters" he http://www.cpearson.com/excel/writin...ionsinvba.aspx Hope this helps / Lars-Åke |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function Declarations !!!!!!!!!!!!!!!!!!!!!!
On Wed, 14 Apr 2010 12:02:01 -0700, Ayo wrote:
How do you declare a variable as OPTIONAL in a UDF. I have a function that I use in one of my macros but I would like to declare at least one of the variables as an optional variable. I am not sure how to do that. Any ideas? Thanks Ayo Look at VBA Help for the Optional keyword. Here's an example, but there are restrictions on its use you should be familiar with. Function foo(s As String, n As Long, Optional o As Variant, _ Optional m As String = "bar") As String .... .... End Function --ron |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function Declarations !!!!!!!!!!!!!!!!!!!!!!
The key thing to remember is that every variable you declare after the first
optional parameter will also be optional (you cannot have required, then optional, then required) Here is a real one from one of my workbooks: Function PullAllRawData(SourceSheet As Worksheet, _ DestSheet As Worksheet, _ Optional PathOnly As String, _ Optional MyFullFilePath As String, _ Optional TitleString As String) In this case, it isn't a UDF, but I'd expect it should work the same way. HTH, Keith "Ayo" wrote: How do you declare a variable as OPTIONAL in a UDF. I have a function that I use in one of my macros but I would like to declare at least one of the variables as an optional variable. I am not sure how to do that. Any ideas? Thanks Ayo |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
declarations | Excel Programming | |||
Declarations Procedure and Duplicate Declarations | Excel Programming | |||
Understanding declarations | Excel Programming | |||
Help with Array Declarations | Excel Programming | |||
Capitalization in Declarations | Excel Programming |