ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Working with Range (https://www.excelbanter.com/excel-programming/419705-working-range.html)

Robin Clay[_4_]

Working with Range
 
This doesn't work in my subroutine:-

-----------------------------
Function MyTest(XRange as Range) as double
......
XMin = MIN(XRange)
MyTest=XMin
......
End Function
-----------------------------

It gives an error "ByRef argument type mismatch"

I don't know -
(a) why, and
(b) what to use instead.

Help, please ?


Regards

Robin

Rick Rothstein

Working with Range
 
Try it this way...

.....
XMin = WorksheetFunction.Min(XRange)
MyTest=XMin
.....

--
Rick (MVP - Excel)


"Robin Clay" <Robin_B DOT Clay AT virgin DOT net wrote in message
...
This doesn't work in my subroutine:-

-----------------------------
Function MyTest(XRange as Range) as double
.....
XMin = MIN(XRange)
MyTest=XMin
.....
End Function
-----------------------------

It gives an error "ByRef argument type mismatch"

I don't know -
(a) why, and
(b) what to use instead.

Help, please ?


Regards

Robin



Michael

Working with Range
 
Trying adding this to your function:
XMin=Application.WorksheetFunction.Min(XRange)
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Robin Clay" wrote:

This doesn't work in my subroutine:-

-----------------------------
Function MyTest(XRange as Range) as double
.....
XMin = MIN(XRange)
MyTest=XMin
.....
End Function
-----------------------------

It gives an error "ByRef argument type mismatch"

I don't know -
(a) why, and
(b) what to use instead.

Help, please ?


Regards

Robin


Robin Clay[_4_]

Working with Range
 
Thank you !

I had tried that, but as
XMin=WorksheetFunction.Min(XRange)
without the "Application" bit.


Regards

Robin


"Michael" wrote:

Trying adding this to your function:
XMin=Application.WorksheetFunction.Min(XRange)
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Robin Clay" wrote:

This doesn't work in my subroutine:-

-----------------------------
Function MyTest(XRange as Range) as double
.....
XMin = MIN(XRange)
MyTest=XMin
.....
End Function
-----------------------------

It gives an error "ByRef argument type mismatch"

I don't know -
(a) why, and
(b) what to use instead.

Help, please ?


Regards

Robin



All times are GMT +1. The time now is 07:04 AM.

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