Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing a range from worksheet to VBA function

Thanks all - I got it to work, thanks to your help!

And yes - this is just for me....

Appreciate the quick response!

Ryan

"Matthew Herbert" wrote:

Ryan,

As a follow on to Jacob's post, are you using this function for yourself or
are you deploying it to others? If you are using it for yourself, then you
know exactly how it works and there won't be any issues with using the
function. If others plan on using it, then you need to consider a few things:

(1) Ensure that the rng1 parameter is only one cell (or adjust the function
to grab only one cell from rng1).
(2) Will the rng2 parameter have more than 32,767 cells in it? If so, then
you need to change the counter to a Long data type.
(3) Will the function need to be called similar to the following: res =
regression(1, Array(3, 4, 5))? If so, you'll need to alter your code to
handle this situation.
(4) Use error messages to force the user to provide the data how the
function needs it, e.g. the returned result could be sting text or the
built-in Excel function errors.

These are only a few thoughts I had when I first read your post in
conjunction with Jacob's reply.

Best,

Matthew Herbert

"Jacob Skaria" wrote:

Function has to return something....(Refer the below for the structure of a
function)

Function regression(rng1 As Range, rng2 As Range) As Variant
Dim intCount As Integer
For Each cell In rng2
intCount = intCount + 1
regression = regression + rng1 ^ intCount + cell
Next
End Function

If this post helps click Yes
---------------
Jacob Skaria


"R Beck" wrote:

Hi all -

I have the following function:

Function regression(x, power())
For i = Lbound(power) to Ubound(power)
regression = regression + x^i + power(i)
Next
End Function

and wish to use the following in Excel

=regression(A1, B1:B3)

But I can't seem to get it to work. What am I missing?

Thanks!
Ryan

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
Trouble with passing a range into worksheet function in VBA [email protected] Excel Programming 3 January 27th 07 12:45 AM
Passing a range to a function David Bell Excel Programming 4 July 8th 06 08:32 PM
Passing a range to a function Isabelle[_2_] Excel Programming 1 January 23rd 06 10:24 PM
passing a range from another worksheet Mike O Excel Programming 4 July 21st 05 05:09 PM
Passing a range into a VBA function Floyd[_2_] Excel Programming 4 February 10th 05 01:29 AM


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