![]() |
Using Range inputs in functions
How can I get the values inputed into a function from a range of values
Below is an example of the values used in the worksheets. A 1 12 2 15 3 36 4 25 5 18 6 23 For a follow up question, does the range selection always have to b in this format, or can I also use the format below: A B C D E F 1 12 15 36 25 18 23 If yes, how would the function determine between formats -- Message posted from http://www.ExcelForum.com |
Using Range inputs in functions
Hi
one way (without much error testing, etc): Function foo_sum (rng as range) Dim cell as range Dim ret_value as double for each cell in rng if IsNumeric(cell.value) then ret_value = ret_value + cell.value end if next foo_sum = ret_value end function And yes you can use a different range layout :-) -- Regards Frank Kabel Frankfurt, Germany How can I get the values inputed into a function from a range of values? Below is an example of the values used in the worksheets. A 1 12 2 15 3 36 4 25 5 18 6 23 For a follow up question, does the range selection always have to be in this format, or can I also use the format below: A B C D E F 1 12 15 36 25 18 23 If yes, how would the function determine between formats? --- Message posted from http://www.ExcelForum.com/ |
Using Range inputs in functions
Curare,
For Each cell in rng 'do something Next cell Either works. If you use Selection, it doesn't need to differentiate. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Curare " wrote in message ... How can I get the values inputed into a function from a range of values? Below is an example of the values used in the worksheets. A 1 12 2 15 3 36 4 25 5 18 6 23 For a follow up question, does the range selection always have to be in this format, or can I also use the format below: A B C D E F 1 12 15 36 25 18 23 If yes, how would the function determine between formats? --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 01:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com