Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Help with using custum functions

Hi every1!!!

I know that if you create a custum function you can return avalue and take
in some parameters as well. So far i have no problems with this.

My problem is could i return more then one value, and not to the same cell,
that this function is being called from.

Example:
This function i need is used on X number or rows. (1000 so far)
Maybe all the rows will have data and maybe not,its dynamic.

So,lets say we figure this out on the data entered on line 1.

This function is called from column D1, and it takes in parameters A1 & B1.

It does a few calculations, and returns the result to calling cell D1,let
say it returns 34.

so it looks like this now:

A1 B1 C1 D1
30 4 -- 34
Could i also return another value from that function to cell C1 for example
something like 17.

so it looks like this:
A1 B1 C1 D1
30 4 17 34

and so one for the next rows that have values, the same thing would be done
as well.(dynamiclly, as needed)

If this is possible how would you do this from VBa, and if its not, is there
a way to do-it anyways.

Please let me know, i just cant figure-out how to copy data into another
cell from a dynamic custum function...

Any help or suggestion will be very much appreciated.
thx again,
PAtrick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with using custum functions

In general, the function can only return a value to the cell in which it is
locations. It can not change anything about another cell. It can not
change formatting for any cell. The exception (and it really isn't an
exception) is a multi-cell array formula. You enter the formula in multiple
**contiguous** cells simultaneously and the function returns an array as a
result. The elements of the array are returned, one to each cell. So in
your specific example, you can update C1 and D1 if you array enter you
formula in C1:D1 and it returns an array

Public Function myFunc(rng1 as Range, rng2 as Range)
myFunc = array(rng1(1)*rng2(1),rng1(1)/rng2(1))
End Function

Selection C1:D1, in the formula bar enter
=MYFUNC(A1,B1)

Entered with Ctrl+Shift+Enter

returns values to both C1 and D1.

--
Regards,
Tom Ogilvy


"Patrick" wrote in message
...
Hi every1!!!

I know that if you create a custum function you can return avalue and take
in some parameters as well. So far i have no problems with this.

My problem is could i return more then one value, and not to the same

cell,
that this function is being called from.

Example:
This function i need is used on X number or rows. (1000 so far)
Maybe all the rows will have data and maybe not,its dynamic.

So,lets say we figure this out on the data entered on line 1.

This function is called from column D1, and it takes in parameters A1 &

B1.

It does a few calculations, and returns the result to calling cell D1,let
say it returns 34.

so it looks like this now:

A1 B1 C1 D1
30 4 -- 34
Could i also return another value from that function to cell C1 for

example
something like 17.

so it looks like this:
A1 B1 C1 D1
30 4 17 34

and so one for the next rows that have values, the same thing would be

done
as well.(dynamiclly, as needed)

If this is possible how would you do this from VBa, and if its not, is

there
a way to do-it anyways.

Please let me know, i just cant figure-out how to copy data into another
cell from a dynamic custum function...

Any help or suggestion will be very much appreciated.
thx again,
PAtrick




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help with using custum functions

I'm working on something similar.

You'll need to create a user-defined array function. Your function
should return an array containing the values you want to write to C1
and D1.

To enter the function into the spreadsheet, select both C1 and D1, type
in the function, and instead of hitting Enter use Ctrl+Shift+Enter.

Search this group for "User Defined Array Function" for more info.
Search Excel's Help for general info on array functions.

Good Luck,
Dave

Patrick wrote:
Hi every1!!!

I know that if you create a custum function you can return avalue and

take
in some parameters as well. So far i have no problems with this.

My problem is could i return more then one value, and not to the same

cell,
that this function is being called from.

Example:
This function i need is used on X number or rows. (1000 so far)
Maybe all the rows will have data and maybe not,its dynamic.

So,lets say we figure this out on the data entered on line 1.

This function is called from column D1, and it takes in parameters A1

& B1.

It does a few calculations, and returns the result to calling cell

D1,let
say it returns 34.

so it looks like this now:

A1 B1 C1 D1
30 4 -- 34
Could i also return another value from that function to cell C1 for

example
something like 17.

so it looks like this:
A1 B1 C1 D1
30 4 17 34

and so one for the next rows that have values, the same thing would

be done
as well.(dynamiclly, as needed)

If this is possible how would you do this from VBa, and if its not,

is there
a way to do-it anyways.

Please let me know, i just cant figure-out how to copy data into

another
cell from a dynamic custum function...

Any help or suggestion will be very much appreciated.
thx again,
PAtrick


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
Custum Cell Format - display 0 (zero) when cell is empty willemeulen[_15_] New Users to Excel 8 May 21st 09 04:03 AM
How to convert cell formula functions to code functions Adnan Excel Discussion (Misc queries) 1 October 1st 08 08:30 PM
efficiency: database functions vs. math functions vs. array formula nickname Excel Discussion (Misc queries) 2 July 14th 06 04:26 AM
Custum Excel RMB Context Menu Peter Huang Excel Programming 0 July 7th 04 10:48 AM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM


All times are GMT +1. The time now is 08:39 AM.

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"