Passing a range to a user defined function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Something like this

Public function MySum(byval rng as Range) as double
MySum = Application.Sum(rng)
end function
 
Back
Top