Hey everyone,
I've got two VBA codes that work really well for what I'm doing, mostly:
- Conditional LINEST function that only finds the x coefficient if the range matches the additional criteria:
Formula example:![]()
Please Login or Register to view this content.
Where Column U are the y's, Column P are the x's, and Column N is where the cells are denoted with "D"s or "R"s, so it's pulling only the "D"s.PHP Code:
=LinestCond($U$2:$U$56,$P$2:$P$56,$N$2:$N$56,"D")
- Weighted LINEST function that gives the x coefficient more weight based on how high the numbers are in the range:
Formula example:![]()
Please Login or Register to view this content.
Where Column P are the x's, Column U are the y's, and Column K is where the cells are weighted from 1-38 so the function knows how much weight to give to each point.PHP Code:
=LinestWeighted($P$2:$P$56,$U$2:$U$56,$K$2:$K$56,TRUE,TRUE)
Again, these both work great -- but I was wondering if somebody more skilled in VBA than I am could help me do two things:
- Come up with a VBA code that combines the two (a weighted *and* conditional) LINEST function; and
- If somebody can help me use these functions to get the y-intercept and not just the x coefficient.
I would be forever grateful! Thanks a lot.
-Ryan
Bookmarks