REGLINP or LinEst vba not work corectly

korneliusz1

New Member
Joined
Jun 3, 2017
Messages
6
Hi again,

with your help function below work.

But only problem is I have some spreadsheets and they have diffrent number of elements. So I wanted to automatize this but I can't.

This function work
Range("N5").FormulaLocal = "=INDEKS(REGLINP(B2:B184; (A2:A184)^{1;2;3;4;5});1)"


There is 2 try of automatic range where LastRow i index of the last Row. REGLINP is the same that LINEST.

This code is for find c5, c4 ... for knowed data
y = c5 * x ^ 5 + c4 * x ^ 4 + c3 * x ^ 3 + c2 * x ^ 2 + c1 * x + b

If you know some other simpler way to do this please write.


One of this ways is from this forum :https://www.mrexcel.com/forum/excel...c-applications-linest-worksheet-function.html
Code:
Dim vCoeff As Variant, vY As Variant, vX As Variant
 
ReDim vY(2 To LastRow, 1 To 1) ' dependent variable with 3 values
ReDim vX(2 To LastRow, 1 To 1)  ' 2 independent variables with 3 values
  
  For r = 2 To LastRow 'LBound(11) 'LastRow ' Or 1 To (Ubound(MyListOfStuff) + 1)


        vX = Cells(r, 1).Value
        vY = Cells(r, 2).Value


 Next r
   
   Dim rY As Range, rX As Range
     Set rX = Range("A2:A" & LastRow)
     Set rY = Range("B2:B" & LastRow)
   
  Range("N5").FormulaLocal = "=INDEKS(REGLINP(rY; rX^{1;2;3;4;5});1)"
   Range("N5").FormulaLocal = "=INDEKS(REGLINP(vY; vX^{1;2;3;4;5});1)"

korneliusz1
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I'm guessing a bit here but perhaps:

Code:
Range("N5").FormulaLocal = "=INDEKS(REGLINP(" & rY.Address & "; " & rX.Address & "^{1;2;3;4;5});1)"

WBD
 
Upvote 0
Your proposition make syntax error

Problem is when i write:
Code:
 Range("N5").FormulaLocal = "=INDEKS(REGLINP(rY.Adress; rX.Adress^{1;2;3;4;5});1)"
I recive in sheet:
Code:
=INDEKS(REGLINP(rY.Adress; rX.Adress^{1;2;3;4;5});1)


I recive text but i would like to recive some data for example B2:B200 insted of rY.Adress
 
Upvote 0
You didn't use the same format as I did. My code:

Code:
Range("N5").FormulaLocal = "=INDEKS(REGLINP(" & rY.Address & "; " & rX.Address & "^{1;2;3;4;5});1)"

Your code:

Code:
Range("N5").FormulaLocal = "=INDEKS(REGLINP(rY.Adress; rX.Adress^{1;2;3;4;5});1)"

You need to use concatenation to construct the formula.

WBD
 
Upvote 0

Forum statistics

Threads
1,215,880
Messages
6,127,519
Members
449,385
Latest member
KMGLarson

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