How to skip a column in a matrix VBA

ybenali

New Member
Joined
Jul 12, 2010
Messages
3
hi everyone,
My program is running a multiple linear regression. The input is a vector "y" and a matrix "x" made for five columns (x1,x2,x3,x4,x5).
The following line is the call of my the multiple linear regression :

ActiveCell.FormulaR1C1 = _
"=LINEST(RC[-8]:R[4]C[-8],RC[-7]:R[4]C[-3],FALSE,FALSE)"

Here is the little trouble: I would like to choose only two columns for my linear regression "x1" and "x3", and not the whole matrix ! I need to skip the second column "x2".

if anyone have a clue, it would be most helpful !!
Thanks !!
 

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.
Thank you !!

I had noticed that ! but can't we set a little sub to unite two columns "x1" and "x3" , and then we'll have a matrix of two columns instead of five columns ?
 
Upvote 0
Hi ybenali
Welcome to the board

Linest() does not accept non-contiguous ranges. You can, however, create an array on the fly using Choose():

Code:
ActiveCell.FormulaR1C1 = _
"=LINEST(RC[-8]:R[4]C[-8],CHOOSE({1,2},RC[-7]:R[4]C[-7],RC[-5]:R[4]C[-5]),FALSE,FALSE)"

Reamark: I'm just giving you a syntax solution for this specific case. With more information maybe there's a better way to do it.
 
Upvote 0

Forum statistics

Threads
1,215,636
Messages
6,125,959
Members
449,276
Latest member
surendra75

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