Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Passing a range to a user defined function

This is probably going sound like a stupid question, but .....
I recently had occasion to write a VBA function for a workbook where one of
the arguments was supposed to be a range of cells, but when I try to use the
function by passing a range in the form of A1:E7, I get an error saying that
that argument is the wrong data type.
Do I need to refer to the range differently?
Was Range the wrong data type to use?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Passing a range to a user defined function

Something like this

Public function MySum(byval rng as Range) as double
MySum = Application.Sum(rng)
end function
--
HTH...

Jim Thomlinson


"Gary Nelson" wrote:

This is probably going sound like a stupid question, but .....
I recently had occasion to write a VBA function for a workbook where one of
the arguments was supposed to be a range of cells, but when I try to use the
function by passing a range in the form of A1:E7, I get an error saying that
that argument is the wrong data type.
Do I need to refer to the range differently?
Was Range the wrong data type to use?

Reply
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 name as an argument to the Index Function Michael Sharpe Excel Discussion (Misc queries) 3 September 5th 12 01:33 PM
user defined function ub Excel Worksheet Functions 6 April 4th 07 09:42 PM
user defined function driller Excel Worksheet Functions 1 November 18th 06 04:51 PM
passing arrays to user defined functions ramki Excel Worksheet Functions 2 February 15th 06 08:34 AM
User defined function linzhang426 New Users to Excel 4 October 10th 05 03:18 PM


All times are GMT +1. The time now is 12:05 PM.

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

About Us

"It's about Microsoft Excel"