Linest, Pivot Tables, and VBA

D

dpchris

I've never posted here before, but I was wondering if I could get some
help from you guys with something I'm working on.

On one sheet of my workbook I have my data and on the other sheet
there's a pivot table referencing all of this data. I'm running a
regression on one explanatory variable, time. The way the data is set
up, Excel is regressing on all available data points. Currently if I
want to regress on only selected data points, like say the latest
twelve months, I have to go into the data sheet and alter the "linest"
function so that only the latest twelve months of data are selected.

As I mentioned before, all this data is tied to a pivot table. The
power of pivot tables is that I can make the pivot table display only
the data I want to see. What I would like to do is create a macro in
VBA that (1) finds the explanatory values I've chosen to display
through my pivot table, like the latest twelve months in keeping with
my example, then (2) finds the "linest" function to which the selected
data points are tied, and (3) alters the function to regress only on
those data points.

If my explanation is confusing, please don't hesitate to ask
questions! I'll try and be as specific as I can to get this problem
solved.

Thanks a bunch!

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top