View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default How to use multiple sheets with range in userdefined function.

AFAIK, there is any way to make that work. 3D worksheet references are
not part of the XL object model or the UDF model.

If you install Laurent Longre's Morefunc utility
(http://longre.free.fr/english/), you can then use the ThreeD function
to convert 3D references into a matrix and use that in your function.
[Note that I haven't had any reason to use the ThreeD function in
conjunction with a UDF.]

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hi to all,

I want to have a userdefined function which accepts a range over more
then one sheet.
eg: MyFunction(Sheet1:Sheet3!A1:B10)

This is code

Public Function MyFunction(ByVal MyArea As ????) As Long
Dim rngCell As Range
Dim lngResult As Long
'
Application.Volatile
'
On Local Error GoTo MyFunction_err

For Each rngCell In MyArea
' Do this and that to calculate lngResult
Next rngCel

MyFunction = lngResult
GoTo CountUniqueValues_exit
CountUniqueValues_err:
MsgBox Err.Description, , Err.Number
MyFunction = -1
CountUniqueValues_exit:
Set UniqueValues = Nothing
End Function

With the standard function SUM you can do this.

I have tried these definitions:
MyFunction(ByVal MyArea As Range) = #VALUE
MyFunction(ByVal MyArea As Variant) = Error 424 / Error 2015 on
MyArea
MyFunction(ByVal MyArea As Object) = #VALUE

Any ideas?