ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   passing reference arguments to VBA function (https://www.excelbanter.com/excel-programming/307346-passing-reference-arguments-vba-function.html)

Mezon

passing reference arguments to VBA function
 
Hi,
Does anyone know how to pass/program the use of the :,
the (space), and the , (comma) reference designation
syntax conventions available to intrinsic Excel funtions
to a single VBA function?
Thanks

Tom Ogilvy

passing reference arguments to VBA function
 
Excel takes care of resolving arguments in the command line. You just
process the results.

For dynamic arguments, one usually uses the parmarray. You then loop
through the array and check the type of each argument and process
accordingly.

As an example with the UDF

Public Function InterpretResults(varr)
msg = TypeName(varr)
If msg = "Range" Then
msg = msg & varr.Address
End If
InterpretResults = msg

End Function

then in the worksheet I have the formula

=InterpretResults(B5:G5 C2:C8)

and the cell displays

Range$C$5

--
Regards,
Tom Ogilvy

"Mezon" wrote in message
...
Hi,
Does anyone know how to pass/program the use of the :,
the (space), and the , (comma) reference designation
syntax conventions available to intrinsic Excel funtions
to a single VBA function?
Thanks




Mezon[_2_]

passing reference arguments to VBA function
 
Thanks Tom, I'll give it a try. John

"Tom Ogilvy" wrote:

Excel takes care of resolving arguments in the command line. You just
process the results.

For dynamic arguments, one usually uses the parmarray. You then loop
through the array and check the type of each argument and process
accordingly.

As an example with the UDF

Public Function InterpretResults(varr)
msg = TypeName(varr)
If msg = "Range" Then
msg = msg & varr.Address
End If
InterpretResults = msg

End Function

then in the worksheet I have the formula

=InterpretResults(B5:G5 C2:C8)

and the cell displays

Range$C$5

--
Regards,
Tom Ogilvy

"Mezon" wrote in message
...
Hi,
Does anyone know how to pass/program the use of the :,
the (space), and the , (comma) reference designation
syntax conventions available to intrinsic Excel funtions
to a single VBA function?
Thanks






All times are GMT +1. The time now is 05:00 AM.

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