How to automate Solver with a Worksheet Change event? - excel

I am working on a sales projection model based on a sigmoid curve. As part of the model, I hope to fit the curve to available historical data, using the sum of squared differences (SUM) between the projection and the historical. The only variable for the curve is its steepness, which I am using Solver to solve for the minimum of SUM.
I hope to make this model more dynamic by allowing users to update the historical figures (highlighted in green) once they become available. But instead of needing to run Solver every time the historical figures are updated, is it possible to automate this by integrating a Worksheet Change event for VBA? I am quite new to VBA, so I'm not too sure how to include a function like Solver into the event.
Attached are screenshots of the model and the parameters for Solver:
https://i.imgur.com/mBS76Wt.jpg
https://i.imgur.com/f8CBcHc.jpg
Thanks in advance for the help!

Related

How to use excel data to find period

I have three Excel columns of data from an experiment with a pendulum: time, angle displacement, and angular velocity. I was wondering if there is a way in Excel to calculate and then graph the period (and, if possible, display the function for the graph)... I realize it's kinda a dumb question. I'm still new at Excel.
Thanks for any pointers u can give!
In case the Analysis ToolPak is installed, one can use Tools->Data Analysis->Fourier Analysis. If the data is a superposition of harmonic functions (sin,cos), the corresponding frequencies (or inverse periods) will appear as peaks in the Fourier analysis.

VBA EXCEL Fitting Curve with freely chosen function

As start situation, I have an xy-chart with some values on it whose progression resemble an exponential function. I need to write a code that draws a fitting curve on the chart, but I have to use a particular function which is not exponential (because I need to get some coefficients from it).
One of the functions i need to use is K(C-x)²/(1+x) whereby k and C are the parameters I need.(They are two and it makes it a lot more complicated) Obviously you can't find this kind of structure on the fitting curve tool in Excel. Is there any possibility to have a fitting curve to a chart where you can write yourself the structure of the function?
Sorry if I don't add any written code, but i just need a hint to start writing.
Thank you
I did something to similar to this a while ago. The approach I took was to use the solver (as gary's student suggests). I think it was fired from VBA but that's unimportant.
Basically you'd have two input cells per row of data with your variables K and C. Then you need to find the difference (errors) between the values the function produces with the values in the input cells compared to the actual values (I think using errors^2 gives quicker conversion). You then sum the differences in another cell. When running the solver, you ask it to minimise the sum of differences by changing K and C.
Does that makes sense...?

tableau waterfall chart with mixed colors

I started working with Tableau and found out how to do waterfall charts (Gantt-charts, rolling sum for y-axis and negative value for length of bar. See here: tableau tutorial waterfall charts)
Now my question would be if there is a possibility to split the color by some category? To show what I'm talking about I set up some waterfalls with excel powerpoint. The first one without a split by a category and the second one with a split by category.
I would appreciate any help
It is as simple as dragging the right field to Color, and adjusting the table calculation.
If it's a simple running sum (for the positioning of the bar), you need to go edit the table calculation, select Compute using Advanced..., then drag all fields to addressing. Then you need to sort your data by the master field (in your case the one that has Coffee, Coke,...) maximum (ascending or descending, doesn't matter).
This way you guarantee that the running sum is being applied to one category at a time (at not one color at a time or something like that).
It's really important to understand the concept of table calculations so you can understand what's going on, how Tableau is calculating stuff. Read this http://onlinehelp.tableausoftware.com/current/pro/online/en-us/help.htm#calculations_tablecalculations_understanding_addressing.html
And if you actually understand what you're doing, it's easier to find a solution. For instance, this hack of Gantt Chart to make a waterfall. What goes on rows the chart will understand at starting point of the data, and what goes on size is, well, the size of the chart. You put negative values cause you want the bar to go down.
That being said, dragging a field to color won't mess up with the size, but it will mess up with the running sum used to determine the starting points. How to solve it? make it calculate all the colors together. How to make it? Understand table calculations and reach my solution.
This is the simple approach, if your database or fields have some peculiarity, this might not work perfectly, and you'll need to explain so I can try to understand how to solve

Microsoft Excel. Piece-wise Least-Squares Fit with Solver. My excel sheet produces right answers sometimes, wrong answers other times

I am trying to do a non-linear regression with data I have for my research. Since it is nonlinear, I can't use Simplex LP. Instead I was doing GRG Nonlinear with upper and lower bounds on all parameters.
It is weird because Excel produces answers that are right sometimes, and other times it is wrong. I have to manually change the parameters to arbitrary numbers, run Solver again, and hope that it is right. Let me show you my excel sheet.
https://drive.google.com/a/case.edu/file/d/0Bw0aJV0lW2eTaHFRUFhobVZ4NWs/edit?usp=sharing
Basically, I am looking to two linear lines to fit the data I have. The raw data can be divided into two portions, both linear. The point which the two lines cross is the Critical Value.
The correct output with my raw data is where the Critical Value = 0.006707. The last time I ran it, which is on the excel sheet, you can see that Critical Value = 3.36E-06.
If it would help you to understand this better in context, I am measuring surface tension of various systems. The critical value is so called Critical Micelle Concentration in my field.
Thanks Guys.
If you are using Excel solver, I think it is falling in local optima. Restarting the solver after setting the different variables to random values may help getting out of local optima values. Before restarting the solver, record the values of the objective function and compare it with the new value found by the solver.
Alternatively, use a better solver outside Excel. There are plenty of open source solvers available on the Internet.

Interpolate off a standard curve in Excel

Most simple thing to do on paper, but somehow near impossible to work out in Excel.
I need to interpolate off a standard curve in Excel.
I have a standard curve and need to find an unknown concentration of a known absorbance.
Just like this;
http://class.fst.ohio-state.edu/fst601/Lectures/spectt/Image161.gif
My lecturer would not give us any more hints than to either use the, linear regression equation (which i think i worked out but couldn't get it to calculate the concentration) or use the point finding/picking option (no idea what this could mean)
If anyone could help me out with this I would really appreciate it, and so would my whole class!
In excel, you can do it two ways:
Method 1: Use a standard interpolation/extrapolation formula. (Bingle)
Method 2: Plot any existing data points that you have as an x-y(scatter) plot. Right-click on the data line in the chart and choose 'Add trendline'. Excel will calculate a best-fit line for your data (using linear regression) and display the line over the top of your existing data. If you right-click on this trendline, you can adjust its settings and display properties of it, including the equation used to draw it. Once you have that equation, you can plug in any value of x and get the corresponding value of y.

Resources