INDIRECT() and named functions

deLockloire

Board Regular
Joined
Apr 4, 2008
Messages
110
Office Version
  1. 365
Platform
  1. Windows
Hey,

I have a couple of named functions (e.g., functions I entered the name manager, gave them names and can not be invoked by entering the names). E.g., two of the named functions are: "exr_average" and "exr_latest" and they return either the latest exchange rate of a selected currency or its average rate in a selected period. Now there is a data validation selector for the currency, the period (with a starting and end date) and the mode of calculation (latest or average).

What I'd like is to construct the string with INDIRECT() and have those named functions work. However, now it does not, and I am unsure if it should or not. Should it? E.g., instead of writing an IF function like this:

VBA Code:
=IF(MODE_OF_CALCULATION="AVERAGE", exr_average, exr_latest)

I'd like to simply construct the name with INDIRECT() like this:

Code:
=INDIRECT("exr_"&MODE_OF_CALCULATION)

Which would execute the exr_average named function if "Average" is selected and exr_latest is "Latest" is selected.

The reason why such a solution would be preferable is because there are more variables at play than I am telling here and then I could avoid long and complicated embedded IFs. Basically the question is if this should at all, in theory, work or not?

Regards,
deL
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
The indirect function needs a valid cell reference, not a defined name.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,038
Members
449,092
Latest member
ikke

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