Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default VBa code for index(linest)

hi everyone

i m trying to write vba code to get coeefiecints of second order
polynomial eequation



Equation: y = (c2 * x^2) + (c1 * x ^1) + b

c2: =INDEX(LINEST(y,x^{1,2}),1)

C1: =INDEX(LINEST(y,x^{1,2}),1,2)

b = =INDEX(LINEST(y,x^{1,2}),1,3)

ihave recorded macro

Cells(j + 2, "D").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-2]:R[2]C[-2],RC[-3]:R[2]C[-3]^{1,2}),1)"
Cells(j + 2, "E").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-3]:R[2]C[-3],RC[-4]:R[2]C[-4]^{1,2}),1,2)"
Cells(j + 2, "F").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-4]:R[2]C[-4],RC[-5]:R[2]C[-5]^{1,2}),1,3)"

but now trying to write VBA CODE for NROWS,NCOLUMNNS]

i hop i wil get direction from this group
many thanks in advance 4 ur efrts n time

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default VBa code for index(linest)

Why not use this as your formula:

Cells(j + 2, "D").Resize(,3).FormulaArray =
"=LINEST(RC[-2]:R[2]C[-2],(RC[-3]:R[2]C[-3])^{1,2})"

What exactly are the NROWS and NCOLUMNS you want? NRows I guess is the span
from R to R[2], so if you define a Long or Int variable nRows, the right
part of the above becomes:

"=LINEST(RC[-2]:R[" & nRows - 1 & "]C[-2],(RC[-3]:R[" & nRows - 1 &
"]C[-3])^{1,2})"

I don't know how you'd use nColumns in this context.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
ups.com...
hi everyone

i m trying to write vba code to get coeefiecints of second order
polynomial eequation



Equation: y = (c2 * x^2) + (c1 * x ^1) + b

c2: =INDEX(LINEST(y,x^{1,2}),1)

C1: =INDEX(LINEST(y,x^{1,2}),1,2)

b = =INDEX(LINEST(y,x^{1,2}),1,3)

ihave recorded macro

Cells(j + 2, "D").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-2]:R[2]C[-2],RC[-3]:R[2]C[-3]^{1,2}),1)"
Cells(j + 2, "E").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-3]:R[2]C[-3],RC[-4]:R[2]C[-4]^{1,2}),1,2)"
Cells(j + 2, "F").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(LINEST(RC[-4]:R[2]C[-4],RC[-5]:R[2]C[-5]^{1,2}),1,3)"

but now trying to write VBA CODE for NROWS,NCOLUMNNS]

i hop i wil get direction from this group
many thanks in advance 4 ur efrts n time



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default VBa code for index(linest)



What exactly are the NROWS and NCOLUMNS you want? NRows I guess is the span
from R to R[2], so if you define a Long or Int variable nRows, the right
part of the above becomes:


thanx Mr. Jon for ur time n effort

wel by nrows and n columns i mean

i want to calculate equation coefficients for unknown set of X,y data

plz stil if its unclear plz let me know

many thanxin advance

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
Color Index Code, is there any thing like that? wilchong via OfficeKB.com New Users to Excel 3 May 22nd 08 01:56 PM
Getting & Using Sheet Names or Index in VBA code rwjack New Users to Excel 4 April 14th 08 01:50 PM
Offset code for dynamic row# & multiple columns in LINEST function RJ Excel Worksheet Functions 3 May 29th 07 06:29 PM
Using INDIRECT in INDEX(LINEST.. ) function Incoherent Excel Worksheet Functions 4 January 10th 06 04:42 PM
How do I refer (in VBA Code) to a column by caption instead of index ? Radu Excel Programming 5 December 9th 05 08:32 PM


All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"