Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Translate range name passed as string to a custom function to range addresses!

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)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Translate range name passed as string to a custom function to range addresses!

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

--
regards,
Tom Ogilvy


"agarwaldvk " wrote in message
...
Hi All

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

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

Function myFunc(rangeName as string)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Translate range name passed as string to a custom function to range addresses!

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

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Translate range name passed as string to a custom function to range addresses!

yes, rng should be dimmed as Range

--
Regards,
Tom Ogilvy

"agarwaldvk " wrote in message
...
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 by
doing so :-

Range(range name)

Great! Thanks again! I have learnt something today!


Best regards


Deepak Agarwal


---
Message posted from http://www.ExcelForum.com/



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
How to use a range in a custom function? Danny Excel Worksheet Functions 5 November 11th 08 12:48 AM
ClearContents method on a passed range bryan New Users to Excel 2 January 19th 05 08:49 AM
Error Converting Passed Range into Array in VBA for Excel Alan Beban[_2_] Excel Programming 0 September 1st 04 04:56 PM
Error Converting Passed Range into Array in VBA for Excel Dave Peterson[_3_] Excel Programming 0 September 1st 04 01:17 AM
Getting a function to return a formated Range string Bob Hillier Excel Programming 1 February 11th 04 08:39 AM


All times are GMT +1. The time now is 06:58 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"