Cell Value in Custom Function

SDowse

Board Regular
Joined
Sep 23, 2009
Messages
120
Hi,

I have created a number of custom functions in Excel, see example below:

=BarclaycardPlanA(Value,Transaction)


The Barclaycard element of the function may change as we have 3 suppliers, ad the PlanA element may change because there is up to 3 plans (PlanA, PlanB and PlanC). Each function I have created is essential SupplierPlan(Value, Transaction).

In my spreadsheet, I have:
C18 = Supplier
C19 = Plan
D22 = CONCATENATE of C18 and C19

What I am trying to do is call the relevant function dependant on what is in C18 and C19. So far in D23 I have got:
=INDIRECT(D22&"("&"Value"&","&"Transaction"&")")

But this returns a #REF ! error. I've searched a bit on the web, but cannot seem to work out what the formula in D23 should be.

Any ideas?

Thanks in advance!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You can't use INDIRECT to call a UDF.

You'd need to create a helper function that you can pass the Supplier and Plan names to as additional arguments (as well as Value and Transaction) and have that call the relevant function using Run, which takes a function name so you can build that up from the inputs.
 
Upvote 0
You can't use INDIRECT to call a UDF.

You'd need to create a helper function that you can pass the Supplier and Plan names to as additional arguments (as well as Value and Transaction) and have that call the relevant function using Run, which takes a function name so you can build that up from the inputs.

Ok, this makes more sense then. Do you have any example code that might be used in a helper function to pass supplier and plan names (as well as Value and Transaction, and how to use Run?
 
Upvote 0
Basically something like this:

Code:
Function HelperFunction(Supplier, Plan, Value, Transaction)
HelperFunction = application.run(Supplier & Plan, Value, Transaction)
End Function
 
Upvote 0
Basically something like this:

Code:
Function HelperFunction(Supplier, Plan, Value, Transaction)
HelperFunction = application.run(Supplier & Plan, Value, Transaction)
End Function

Thanks again for your help, and apologies if I am asking stupid questions...

I assume in my worksheet I would enter =HelperFunction(Value,Transaction)? If so, it is returning a #Value ! error...is there anything I need to do in order to make this work? Any pre-cursors or anything?

Thanks again!
 
Upvote 0
No you need to pass 4 arguments not two. The first two are the supplier and plan names.
 
Upvote 0
Glad to help. We were all beginners once! :)
 
Upvote 0

Forum statistics

Threads
1,223,715
Messages
6,174,064
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top