Translate range name passed as string to a custom function to range addresses!

A

agarwaldvk

Hi All

I am trying to write a custom function where I am passing a range nam
as a string. This range name can comprise of 1 or more range area
delimited by commas (,). These range areas may or may not be contiguou
areas.

For example, if my custom function is called "myFunc()" this is how i
will look like (shown below) :-

Function myFunc(rangeName as string)
 
T

Tom Ogilvy

Function myFunc(rangeName as string)
dim dblSum as Double
set rng = Range(rangeName)
for each cell in rng
if isnumeric(cell) then
dblSum = dblSum + cdbl(cell.value)
end sub
Next
myFunc = dblSum
End Sub
 
A

agarwaldvk

Tom

Thanks a lot for your quick response. Greatly appreciated.

I take it that "rng" is to be dimmed as Range.

I didn't know a range name could be converted to a range simply b
doing so :-

Range(range name)

Great! Thanks again! I have learnt something today!


Best regards


Deepak Agarwa
 
Top