ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a named range to a function (https://www.excelbanter.com/excel-programming/421669-passing-named-range-function.html)

Mike M 91107

Passing a named range to a function
 
I have a named range called "Temperature" that is 1 x 10 vector.

I have a function x(ByVal value1 as double, Byval value2 as double) that I
need to run on all 10 temperatures.

When I go x(4,5) the function works.

When I go x(Temperature,5) the function gives #VALUE! error. My intent is
that the function will pull the Temperature value from the vector in the
column above it (or row beside it).

Little help?

Rick Rothstein

Passing a named range to a function
 
Hard to know what you are trying to do, and hence it is hard to make
specific recommendations, when you hide the code from us. I can tell you
that your first argument is expecting a simple variable of type Double and
you are attempting to pass a Range (which is not a simple variable) into it.
You might be able to overcome that by using a Variant, then testing the type
of data that was passed in and reacting to that. Again, seeing your code
would make it easier to recommend something. By the way, is the Temperature
range **always** the one you want to do your calculations from... or could
there be other named ranges that the function will need to be able to
process?

--
Rick (MVP - Excel)


"Mike M 91107" wrote in message
...
I have a named range called "Temperature" that is 1 x 10 vector.

I have a function x(ByVal value1 as double, Byval value2 as double) that I
need to run on all 10 temperatures.

When I go x(4,5) the function works.

When I go x(Temperature,5) the function gives #VALUE! error. My intent is
that the function will pull the Temperature value from the vector in the
column above it (or row beside it).

Little help?




All times are GMT +1. The time now is 10:58 AM.

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