LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Simple example of a range argument to a UDF?

Can someone show me a simple example of how to pass a range of cells
to a UDF and then how to address them in the UDF?

Suppose I have two rows of paired parameters (X and Y)

A B C D
1 X X1 X2 X3
2 Y Y1 Y2 Y3

I need to write a regression function that will operate on the pairs
from column B to successive columns to the right.

I understand that I can pass a range to a UDF something like this:

A B C D
1 X X1 X2 X3
2 Y Y1 Y2 Y3
3 f(x,y) =F(B1:B1,B2:B2) =F(B1:C1,B2:C2) =F(B1:D1,B2:D2)

Suppose I wanted to compute the sum of the product pairs (X1*Y1),
(X1*Y1 + X2*Y2), (X1*Y1 + X2*Y2 + X3*Y3), ...

What would the VBA code look like? My function is a lot more
complicated than that and involves looping, but if I had the code for
this simple sum of products, I could adapt it.

Thanks
 
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
simple copy paste multiple range macro ARGUMENT ERROR Bruno Excel Programming 2 October 22nd 08 01:33 AM
Difference function and argument for two simple amounts lawrencae Excel Discussion (Misc queries) 8 January 5th 08 12:52 PM
Function (array argument, range argument, string argument) vba Witek[_2_] Excel Programming 3 April 24th 05 03:12 PM
Range as argument in function Asif[_3_] Excel Programming 3 December 6th 03 01:38 PM
Passing range as argument Jan Kronsell[_2_] Excel Programming 3 September 3rd 03 12:31 PM


All times are GMT +1. The time now is 11:15 AM.

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"