Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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/



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
Selecting series in a chart based on a range and manual inputs Tigerxxx Excel Discussion (Misc queries) 0 July 19th 09 12:36 AM
Using range names in functions JDC Excel Worksheet Functions 1 May 11th 09 04:53 PM
Dynamic Range Name in Functions Carrie_Loos via OfficeKB.com Excel Discussion (Misc queries) 0 August 5th 08 09:56 PM
How to use functions after sorting a range? R13 Excel Worksheet Functions 2 April 4th 07 02:44 PM
Define inputs and outputs to make functions from sheets Prophet of Nixon Excel Discussion (Misc queries) 1 January 10th 05 05:16 PM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"