Add-in 'Solver' To Automatically Find A Value In Vba
Jul 25, 2009
I would like the XL add-in 'Solver' to automatically find a value 'M' in the equation attached, based on 'R' being 30%.
I also would like to be able to manually enter 'M' based if I would like 'R' to be different from 30%.
How can I program this in VBA, and have the equation automatically done in the first instance simply by clicking on cell 'R'.
View 2 Replies
ADVERTISEMENT
Oct 17, 2006
I have a proyect evaluation. I use solver to find a value, which works. I recorded a macro for this situation (which repeats all the time), but when I run it, it does not work. The problem is not the answer, it is that the macro does not run
Sub TIR()
SolverOk SetCell:="$M$41", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$44"
SolverSolve
Range("E44").Select
End Sub
View 2 Replies
View Related
Mar 18, 2009
I'm trying to use solver to find the minimum value of a cell by changing 5 separate cells. These cells are subject to a set of constraints that are formulae. On top of that I have a large number of these solve's to run (The spreadsheet is creating randomly distributed data to form a Monte Carlo simulation). Therefore I am referencing the formulas using the ActiveCell, Offset() function. For some reason when running this code none of the values are changed. Also I changed the UserFinish to false so I could see what solver was doing at each solve, It stops at the correct cell (one after the final cell) but without me having to confirm it each time.
Here is the ....
View 3 Replies
View Related
Sep 10, 2006
I have a cell, D5, which is the sum of three other cells, A5 B5 and C5. (all currently empty). Cells A1 through C4 are filled with various numbers.
What I've been trying to do is use solver to say: Make D5 equal 200, do it by manipulating only A5 B5 and C5, and make it subject to the constraint that A5 must equal a value selected from A1:A4, and B5 must equal a value from B1:B4, and C5 ...etc. I have deliberately set it up so that there is only one solution.
I was doing fine until trying to create the constraints. How can I make a constraint that says "this cell" must equal "one of the following cells"? And if I can't do that, is there an alternate method of achieving the same result?
View 9 Replies
View Related
Jan 12, 2007
I have to use use the solver to calculate something (a mean-variance framework).
I am using the solver to minimize a cartain cell (variance) by making two cells equal through (expected return) by varying 10 cells( weights of assets), but I have to repeat this for 500+ times (for different expected returns).
Someone told me that I could best use some sort of loop through VBA. But I don't have a clue how that works.
View 13 Replies
View Related
Jan 21, 2009
I want to use solver program. But when solver "changes cells" i want it to trigger my pivot tables in the workbook. So i added the code to my worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
ThisWorkbook.RefreshAll
End Sub
So when a change occurs, all my pivot tables will get refreshed and my data will change. Is solver able to trigger this event while solving an optimization problem?
View 9 Replies
View Related
Jan 20, 2010
I need to do is find a way to automatically find a range and once the range is determined i gotta put on those rows a function [Today()- a date], i know the functions i gotta use but don't know how to set that range automatically and copy or apply the function in those rows in a different column of course.
View 11 Replies
View Related
Mar 2, 2009
I have a formula to add the volume (units) for a customer. The formula is:
=E5+E10+E21+E31+E38+E52+E65+E69
Is there a formula that I can use instead of the one above that will find the customer number and automatically sum the units?
View 9 Replies
View Related
Mar 19, 2012
I am trying to find a formula that will automatically fill in text that is entered in Sheet1 if it matches with a name in Sheet 2. I have found a formula that will enter a number but it will not work for text.
=SUMPRODUCT(Sheet 1!$C$3:$C$31,--(Sheet 2!$B$3:$B$31=$A15))
I would like the job on sheet 2 column B to fill in from what is listed next to their name on Sheet 1 column C, if the name of the person is entered on Sheet 2.
Sheet 1
NameJob1MaryFile2JohnLog3SallyIntake4PeterPack
Sheet 2
Staff Name &JobMary0John0Sally0Peter0
View 3 Replies
View Related
Aug 20, 2007
I am trying to find a way to automatically find and replace 2 letter symbols in a specific column into the words they represent. There are many symbols and rather than do a find and replace for each symbol, I would like to write a macro that would do them all at once.
View 9 Replies
View Related
Apr 25, 2008
I have a Table with MB and GB numbers.
I copy and Paste these into Excel, What I need, is for Excel to Automatically convert the MB into GB by /1024
I tried something like this
=REPLACE(A1,FIND("MB",A1),9,"(But can I enter a Maths here)")
View 9 Replies
View Related
Jul 30, 2012
I have 2 columns of data
column A = weeks (A2:A50) i.e. P1W1, P1W2, P1W3....P12W4 etc
column B = headcount (B2:B50) i.e. 5, 7, 5...10 etc
Essentially my criteria is "looking for last week and give me headcount" i.e. my lookup criteria is P7W5 ....however if P7W5 has no data, i want the lookup to go up or offset to the row above (it may be one to 4 rows above)....
View 3 Replies
View Related
Mar 22, 2009
I am trying to organize it in a way that I can have all my purchases added based on my text criteria of certain purchase... Ill try to be as clear as possible. I have already organized it in a way that when I paste new months statement in my Excel file it sorts it by date, newest on the top, and I made Conditional Formatting by color on column D which states the Description of purchase. Starbucks appears in description cell but it is followed by number and location making each Starbucks cell in column D different in name. So its hard to use Exact phrase formula to combine the amount for that purchase.
My question is: Is there a formula that find a PORTION of text in a D column and automatically adds the price to the right of it together in one cell. There is a formula that looks for the whole text in the cell but that doesn't work when my name has always some extra numbers at the end of the word Starbucks
View 2 Replies
View Related
Feb 14, 2008
I am trying to drive Solver in Excel 2000 with a Visual Basic (version given as 9969) macro. SolverReset is observed, and SolverAdd puts the constraints in. But the SolverOK statement does nothing, so the SetCell and the ByChange windows stay empty.
SolverSolve is trying to do something, because the spreadsheet cell that should receive the return code from Solver gets an error value #VALUE! (The macro then stops, unable to process this entry.)
Solver is checked off ok in the References list in V.Basic.
The same macro, same spreadsheet, in the same Excel file, works fine on the other computer in my office with what I am told is a more recent version of Excel; i.e. this doesn't look like a coding error.
View 4 Replies
View Related
Jun 2, 2009
I wanted to see if I could use the solver to Solve Sudoku puzzles. I created the attached workbook. First it colors the numbers that are put in manually, which would be the starting puzzle. I have a generic one put in now. Then it finds which cells that are allowed to change. Then it is supposed to solve. It doesn't work. Run the Sheet1.SolvePuzzle Macro to see it not work. Is solver just not up to the task, or am I missing something?
View 2 Replies
View Related
Feb 20, 2010
I recorded a macro using 'Solver'. When I try to run it, I get a message"Complie Error: Sub or Function not defined". Can anyone help me?
Heres the
Sub Macro1()
SolverOk SetCell:="$R$4", MaxMinVal:=3, ValueOf:="4275", ByChange:="$S$4"
SolverSolve
End Sub
I also tried this
Sub SolverMacro()
' Example Solver VBA Macro
SolverReset
SolverOk SetCell:="$R$4", MaxMinVal:=3, ValueOf:="4275", ByChange:="$S$4"
SolverSolve userFinish:=True
End Sub
View 6 Replies
View Related
Dec 21, 2006
can I program a macro to run solver? ...
View 9 Replies
View Related
Feb 4, 2008
I need to solve this using solver. I have an idea, but I'm not sure what to in regards to my objective function, and how to properly set up my constraints. I know I need to use sumproduct, but I'm not sure in what way. I'm using Excel 2007, here is the problem:
The Sweet Smell Fertilizer Company Markets bags of Manure is Combination of compost and Sewage Wastes. Each pound of Compost costs sweet smell $0.05 and has a fertilizer rating of 2 units. Each pound of sewage costs $0.004 and has a fertilizer rating of unit. To provide good quality fertilizer, each bag should contain at least 35 pounds of compost, not more than 40 pounds of sewage, and have total fertilizer rating of at least 100 units. Determine the lowest-cost blend of compose and sewage in each bag.
Here is what I have so far: ....
View 9 Replies
View Related
Nov 17, 2008
I created a trendline and associated equation for some data plotted against Time on the x-axis displayed in MM/DD/YY format. The date for the data ranges from 3/27/06 thru 11/10/08.
The trendline equation is
F(x)=-6E-13x^5+1E-07x^4-.0087*x^3+329.1*x^2-6E+06*x+5E+10
The data actually crosses the y=0 line around 11/5/07, which is the data root
When I use Goal Seek, I got a zero root solution of 28154.98. When I convert this to the date format, it converts to a date in 1981 which is not correct. I tried a range of initial guesses but they all converge to the same number.
View 9 Replies
View Related
Jan 14, 2009
I am using solver to solve an optimisation problem I have. I need to apply a new solver to every populated row of my sheet. My solver code is as follows:
Sub solverloop()
SolverOk SetCell:="$Z$2", MaxMinVal:=3, ValueOf:="0", ByChange:="$N$2:$O$2"
SolverSolve
End Sub
The code above applies the solver to row 2. My sheet has roughly 500 populated rows. I need to write a macro to loop solver over each row, accept the solution provided by solver, then move to the next row. i would also like to close the loop automatically when the last populated row is reached.
View 9 Replies
View Related
Nov 2, 2006
I'm trying to run a macro which will allow me to run solver and keep the solution.. I have managed to get the macro to work. However, does anyone knows how I can ensure that solver's solution can be automatically saved without prompting the user whether to save the solution?
View 2 Replies
View Related
Nov 8, 2006
I am having problems with this excercise on my worksheet in my business computing class. I was wondering if someone could guide me through on how to use the solver feature.
Excercise:
Eve Blue is the manager of Southland Furniture store and she is planning a New Years Day sale. The store has only 75 square feet of space available to display and stock this merchandise. During the sale each folding table costs $5, retails for $11 and takes up two square feet of space. Each chair costs $4, retails for $9 and takes up one square foot of space. You must order at least one chair and one table and, of course, they must be whole units. The maximum amount allocated for purchasing the tables and chairs for the sale is $280. Eve cannot sell more than 40 chairs but the demand for tables is unlimited. Eve asked you to help her determine how many tables and chairs she should purchase in order to make the most profit.
Layout: (I marked in x's where I need to solve.)
TablesChairs
Unit Wholesale Cost $5.00 $4.00
Unit Retail Price $11.00 $9.00
Profit per Unit $6.00 $5.00
Square feet per Unit 2 1
Quantity to Order x x
Total Cost $- $-
Total Profit $- $-
Total Square Footage00
TOTAL ORDER COST $-
TOTAL ORDER PROFIT $-
TOTAL SPACE REQUIRED0
View 3 Replies
View Related
Mar 23, 2007
At work, we have a spreadsheet that uses SOLVER.XLA in a macro. It works fine in Excel '97 but in Excel 2003 it simply does nothing. The code is
s = Application.LibraryPath & "solversolver.XLA"
On Error Resume Next
Workbooks.Open filename:=s
Application.ExecuteExcel4Macro String:="SOLVER.XLA!SOLVER.RESET()"
Application.ExecuteExcel4Macro String:="SOLVER.XLA!SOLVER.OK( PLOT!R46C4,2,0,(PLOT!R13C12:R14C12))"
Application.ExecuteExcel4Macro String:="SOLVER.XLA!SOLVER.OPTIONS(100,100,0.000001,FALSE,FALSE,2,1,1,0.05,TRUE)"
Application.ExecuteExcel4Macro String:="SOLVER.XLA!SOLVER.OK(PLOT!R46C4,2,0,(PLOT!R13C12:R14C12))"
Application.ExecuteExcel4Macro String:="SOLVER.XLA!SOLVER.SOLVE()"
ActiveSheet. Protect DrawingObjects:=False, Contents:=True, Scenarios _
:=True, password:="sigma"
It gives no error message, it simply does not do the calculations. (I took out the error handling line to make sure that there really were no errors being generated!)
View 3 Replies
View Related
Apr 24, 2007
I am trying to get Solver to list a combination of invoices which make exact specified amount of close to...
attached is an example, maybe im doing it completely wrong, or other tools can be used...
View 9 Replies
View Related
Jan 27, 2014
I'm having issues getting solver to use the minimum and maximum for hours and items to be produced. I can't seem to get a balance between the two.
Solver 1.xlsx
View 3 Replies
View Related
Nov 11, 2008
I have the following dataset and was wondering how I can run a constrained regression in Excel with the constraint being that the total allocation of assets is 100%:
Total return (y): 12 data points
Asset 1 (x1): 12 data points
Asset 2 (x2): 12 data points
Asset 3 (x3): 12 data points
Asset 4 (x4): 12 data points
Asset 5 (x5): 12 data points
Asset 6 (x6): 12 data points
[Attached is a spreadsheet with the actual dataset]
I know the regression equation I need is R = b1X1 + b2X2 +
.+ (1 - b1 - b2 -
.- b5 )X6 + e
View 14 Replies
View Related
Jan 11, 2009
I have a problem with a macro in Excel 2007. It invokes
solver and creates an answer report. Please find the VB
code for macro, below.
View 7 Replies
View Related
Jan 25, 2010
When I run a group of macros for some reason after the marcro runs and I hit F2 excel crashes.
I have figured out that it is one of the marcros that makes the excel crash. It is only when I run the solver application. The code is below. Any thoughts why hitting F2 after running this marcro would crash the machine?
View 10 Replies
View Related
Jan 11, 2010
See my file. I want to calcuate a % needed (20%) to add to a another material. Should be easy but I can not figure it out.
View 3 Replies
View Related
Aug 4, 2009
My macro uses the solver 100 times. Everything is working well, but it's a little bit slow because of all the cell references.
I was wondering if it's possible to use the solver with variables without cell references?
View 4 Replies
View Related