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

  • Thread starter Thread starter agarwaldvk
  • Start date Start date
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)
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top