array formula variable range size

iceaxesun

New Member
Joined
Nov 19, 2012
Messages
2
I am using a linear regression array formula that uses a range of three columns, X, Y, and Yerror. Works great. However, the number of data points is variable. Is there a way to make the array formula detect the size of the range, or to ignore empty cells at the end of the range.


The array formula is


=LSFit(C9:C17,D9:D17,E9:E17), an add-in that computes weighted least squares fit with errors.


I have tried LSFit(if(C9:C17<>"",C9:C17),if(D9:D17<>"",D9:D17),if(E9:E17<>"",E9:E17)), but this returns DIV/0 just the same if blank lines are included in the array formula.


Is there a way to accomplish this, or do I need to resize the ranges in the formula each time I have a different number of inputs?

I have done this with loops in VBA, but would rather keep this simple.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi
Welcome to the board

There are several ways to do it. THis is one.

Let's assume the values start in row 9 go down in contiguous cells up to maximum row 50. You can

- calculate how many X values there are. For ex. in A1:

=COUNT(C9:C50)

- Use the formula:

=LSFit(C9:INDEX(C9:C50,A1),D9:INDEX(D9:D50,A1),E9:INDEX(E9:E50,A1))
 
Upvote 0
Sweet and simple. Thanks much!

I am wondering if this will work for chart series that include trailing blank cells, as well.
 
Upvote 0

Forum statistics

Threads
1,216,122
Messages
6,128,964
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top