LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default user defined function receiving a range as parameter

Hi everyone,

I have created a UDF receiving a range very similar to the SUM function but
it works only on ranges that do not contain the worksheet names.

For example, I can do :
= MyFunction(A1:B3) like I could for =SUM(A1:B3)

I receive the range correctly and I can go thru the cells of the range.

But when I move to a more complex range like :
=MyFunction(Sheet1!A1:Sheet8!A1) like I could do for =SUM(Sheet1!A1:Sheet8!A1)

My macro does not even start and the cell is filled with "#VALUE!"

Simple macro really. Here is the code :

Function MyFunction(sel As Range) As String
MyFunction = Empty
For i = 1 To sel.Count
If (sel.Cells(i).Value < Empty) Then
If (MyFunction < Empty) Then
MyFunction = MyFunction + ", " + sel.Cells(i).Worksheet.Name
Else
MyFunction = sel.Cells(i).Worksheet.Name
End If
End If
Next i
End Function


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a range to a user defined function Gary Nelson Excel Discussion (Misc queries) 1 July 19th 07 04:22 PM
vlookup, add parameter, on error return user defined value jims2994 Excel Worksheet Functions 0 July 7th 06 02:56 PM
extract parameter VALUE form a user-defined function.. perove Excel Programming 1 August 8th 05 05:09 PM
User defined functions - parameter descriptions Heidi[_4_] Excel Programming 7 July 20th 04 08:03 PM
Using linked workbook as a parameter in a user defined function Michael[_20_] Excel Programming 1 November 28th 03 05:03 PM


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"