ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test for empty array is 'UBound(AName) -1'. (https://www.excelbanter.com/excel-programming/426762-test-empty-array-ubound-aname-1-a.html)

[email protected]

Test for empty array is 'UBound(AName) -1'.
 
For any newish-bies out the

I just discovered that, at least in this context, the inline test to
determine whether the user passed any arguments or not is:

function MyFunc(ParamArray MyArgs)
if UBound(MyArgs) -1 then
<...
else
MyFunc = "Eh, paisan, you wanna passa me an argument?"
endif

joel

Test for empty array is 'UBound(AName) -1'.
 
See VBA Help

Understanding Named and Optional Arguments


You need to use the ISMISSING statement

if Not Ismissing(MyArgs)
<...
else
MyFunc = "Eh, paisan, you wanna passa me an argument?"
endif


" wrote:

For any newish-bies out the

I just discovered that, at least in this context, the inline test to
determine whether the user passed any arguments or not is:

function MyFunc(ParamArray MyArgs)
if UBound(MyArgs) -1 then
<...
else
MyFunc = "Eh, paisan, you wanna passa me an argument?"
endif



All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com