Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

multiform userdefined functions

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Multi-form User-defined Functions

Multi-form User-defined Functions

ResolvedVersion 2010

Michael has attended:
Excel Advanced course
Excel VBA Intermediate course

Multi-form User-defined Functions

The built-in INDEX function contains 'two forms', an array form and a reference form. This allows users to obtain an output even if their data-set slightly differs from another data-set.

Is it possible to create a two form (or multi-form) UDF in VBA?

RE: Multi-form User-defined Functions

Hi Michael,

Thank you for the forum question.

Yes everything (almost) is possible in VBA.

What exactly do you mean by creating a two form or multi form UDF in VBA.

When you create UDFs you can work with optional arguments. The build-in index function have two options. It can find data in one array using =index(Array,Row_Num,Col_Num) or in multiple Arrays using =index(Reference,Row_Num,Col_Num,Area_Num).

What do you need with your UDF?


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Multi-form User-defined Functions

So I've created a function that generates an equation for a payoff diagram, or if the optional variable is provided, a profit diagram:


Function ECallG(LongPos As Boolean, Price As Integer, Strike As Integer, Underlying As Integer, Optional Quantity As Integer) As Long
'Provide an equation to graph a European Call Option's payoff, or profit if Quantity > 0
If Quantity > 0 Then
'Generate a profit graph
If LongPos = "True" Then
ECallG = Application.Max(-Price, (Underlying - Strike - Price)) * Quantity
Else: ECallG = Application.Min(Price, -(Underlying - Strike - Price)) * Quantity
End If
Else
'Generate a payoff diagram (do not consider the cost of acquiring the option)
If LongPos = "True" Then
ECallG = Application.Max(0, (Underlying - Strike))
Else: ECallG = Application.Min(0, -(Underlying - Strike))
End If
End If
End Function


I want to remove the main IF statement, and have a setup that returns a two-form function that is visual similar to the INDEX function.

RE: Multi-form User-defined Functions

Hi Michael,

As I said in my answer "Yes everything (almost) is possible in VBA."

Unfortunately I am not been able to find a solution. I have been around in cyber world but have not been able to find what you need. I have also asked the other VBA trainers for help but they couldn't help me.

Sorry I cannot help you with this one.

I had some ideas by trying calling another function from the main function but make it visible like the index function was not possible for me.


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Wed 9 Mar 2016: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Colouring cells containing formulas

Cells in a worksheet can contain values or they can contain formulas. You may wish to identify all the cells in your worksheet that contain formulas by colouring those cells.

Follow these steps:
1. Choose Edit > Go To menu, or press either F5 or Ctrl+G. Excel displays the Go To dialog box.
2. Click Special. Excel displays the Go To Special dialog box.
3. Select the Formulas radio button option.
4. Select OK.

At this point, every formula cell in the worksheet is selected, and those cells can be coloured formatted as desired.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.16 secs.