ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Functions with multiple inputs? (https://www.excelbanter.com/excel-programming/378614-functions-multiple-inputs.html)

Nicolas[_3_]

Functions with multiple inputs?
 
I couldn't make a function with a matrix as input. My idea is to write a
macro (a function in VBA for Excel) witch reeds a matrix (of variable size)
and develops a number. The problem is that I can't find the way to write the
function with multiple inputs (like the function SUM(A1:A5) )

Does anyone knows how to do that?

Nicholas


Niek Otten

Functions with multiple inputs?
 
Hi Nicholas,

Function Testa(RangeA as Range) as Double

What do you want the function to do?
Maybe this example function is af help to you

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

================================================== ========
Function VLookupSort(SearchArgument As Range, SearchTable As Range, _
ColumnNo As Long, Optional SortDirection, Optional NotFound)
' Works as Vlookup, exact match (4th argument = FALSE)
' But takes advantage of the fact that a table is sorted
' and thus is much faster
' Also permits table to be sorted descending (Sortdirection -1)
' Optional argument for return value if item not found, defaults to #NA
Dim ItemFound

If IsMissing(SortDirection) Then SortDirection = 1

ItemFound = Application.Match(SearchArgument, Intersect(SearchTable, SearchTable.Cells(1).EntireColumn), _
SortDirection)
If SearchTable(ItemFound, 1) < SearchArgument Then
If IsMissing(NotFound) Then
VLookupSort = CVErr(xlErrNA)
Else
VLookupSort = NotFound
End If
Else
VLookupSort = _
SearchTable(ItemFound, ColumnNo)
End If
End Function
================================================== ========

"Nicolas" wrote in message ...
|I couldn't make a function with a matrix as input. My idea is to write a
| macro (a function in VBA for Excel) witch reeds a matrix (of variable size)
| and develops a number. The problem is that I can't find the way to write the
| function with multiple inputs (like the function SUM(A1:A5) )
|
| Does anyone knows how to do that?
|
| Nicholas
|



[email protected]

Functions with multiple inputs?
 
You could just have one input variable - try using a Collection and the
calling method can populate it with whatever you need in it. You can
then process through it using For...Next logic.



Nicolas wrote:
I couldn't make a function with a matrix as input. My idea is to write a
macro (a function in VBA for Excel) witch reeds a matrix (of variable size)
and develops a number. The problem is that I can't find the way to write the
function with multiple inputs (like the function SUM(A1:A5) )

Does anyone knows how to do that?

Nicholas



Nicolas[_3_]

Functions with multiple inputs?
 
Finally I could write the macro as a Function.
I don't have to use the Sub anymore.
Thank you very much.


En del 2/12/06 15:27, "Niek Otten"
escribió:

Hi Nicholas,

Function Testa(RangeA as Range) as Double

What do you want the function to do?
Maybe this example function is af help to you




All times are GMT +1. The time now is 01:29 PM.

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