Amend Formula range based on how many cells in range are blank.

D_Spark

Board Regular
Joined
Feb 4, 2007
Messages
232
In a workbook I have the following formula

=LINEST(B2:B4,A2:A4,FALSE,TRUE)


What Im want to achieve is to amend the formula so that the ranges move based on how many cells have values.


Eg1

If

B2 contains a value
B3 contains a value
B4 contains a value
B5 contains a value
B6 is blank
B7 is blank
B8 is blank
B9 is blank
B10 is blank
B11 is blank
B12 is blank

Then

The formula would be

=LINEST(B2:B5,A2:A5,FALSE,TRUE)


Eg2

If

B2 contains a value
B3 contains a value
B4 contains a value
B5 contains a value
B6 contains a value
B7 contains a value
B8 contains a value
B9 contains a value
B10 contains a value
B11contains a value
B12 is blank



Then

The formula would be

=LINEST(B2:B11,A2:A11,FALSE,TRUE)
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Something like this maybe:

=LINEST(B2:INDEX(B2:B12,MATCH(9.9E+307,B2:B12,1)),A2:INDEX(A2:A12,MATCH(9.9E+307,B2:B12,1)),FALSE,TRUE)
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,472
Members
452,915
Latest member
hannnahheileen

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