Solver Automation VBA Code

Dec 31, 2008

I've done quite a bit of research in the past week or so on the topic of solver automation using loops; while there are a few good posts scattered around, i haven't quite found the solution to my problem.

i'm trying to run the solver on a few like-sized datasets contained in one worksheet. i've set up a loop to properly reference the 4 datasets. the solver constraints are in one column on the same worksheet.

the macro runs with no errors, but it doesn't "solve." the parameter cells retain their original values.

i should mention that my macro ran perfectly before i consolidated the 4 separate solver calls into one loop. I got tired of having to type 4 different constraint changes in the code as i was optimizing the solver.

on a similar topic, does anyone know how to call a variable in the FormulaText declaration? If i wanted to step through a defined array of constraints, say [1,2,3], how do i get FormulaText:= variable to work?

Sub Macrosolver()

Dim iteration As Long
Dim i As Integer
i = 8 'start in row 8 at first dataset

View 4 Replies


ADVERTISEMENT

Automation Of Solver: Must Inputs Be Derived From Cells?

Jan 20, 2010

I'm trying to automate the solver using a vb program. I have found this example which is just about spot on for my needs:

View 4 Replies View Related

Advanced Filter Code Re Automation

Jun 19, 2009

I'm trying to automate advanced filter but can't get past having just 1 critreria.
I have attached an example spreadsheet where the download dump is on "Data" sheet and the result of the advanced filter is on the "Result" page. I would like, if possible, for the result to come up every time the criteria is put in (they are all data validation lists).

so for example, if i select account code, all those codes come up then select period and the list dwindles down and again for cost centre. Is it possible to do this without using macros. I have found the following code butnot sure what to do with it (sorry).

View 2 Replies View Related

Automation Error With Userforms InVBA Code

Jun 25, 2009

So I haven't seen this error before. It says "Automation error: the object invoked has disconnected from its clients."
I think I know what's causing it but am not sure how to go about solving the problem.
Barring any inefficiences that the code below contains, can someone please tell me what code I should used to fix this error?

View 8 Replies View Related

Set Solver Reference In Code

Nov 23, 2006

my excel sheet runs through different cases (i=1 till i=20). For each case I need to use the solver. Since the whole programm works with references like this cells(10 + i, columnindex).value I tried this with the solver, too. e.g.: SolverOk SetCell:=Cells(20 + i, 46), ValueOf:="0.000001", ByChange:=Cells(20 + i, 47)

But it gives me not a right result as it would give me with a reference like
SolverOk SetCell:="$AT$21", ValueOf:="0.000001", ByChange:="$AU$21"
I tried difference referencing things with different types of brackets, wih range, etc. but I could not figure it out hwo it might works.

View 4 Replies View Related

Solver With Code-Generated Model

Dec 14, 2009

Suppose that you have some data points and you want to fit a straight line to them. You write the line's equation in the cells ajacent to your data points, make the square of each difference, sum up all the squares and you have your objective function. Of course your line equation depends on two parameters, that you enter in two cells. Then you run the Excel Solver, enter your objective function as target cell to minimize, enter the range containing your parameters, set your constraints and off you go.
So far so good.

And now suppose that in order to generate your model data it is not enough to write a straight line equation in some cells, but rather to run a complete reactor model (contained in a macro). How do I couple that model-generating macro with the Excel Solver? Now, I actually found a solution. I wrote a Worksheet_change macro in the sheet containing the model parameters, which calls the model-generating code each time the parameters are chenged by the Excel Solver. This has worked fine for a simple example as the straight line one.

Now one of the two:.....

View 4 Replies View Related

How To Use Solver Add-in Then To Create Own Data Analysis Code

Nov 18, 2011

Is it easier to use the Solver Add-in than to create your own data analysis code? We are planning to design a scheduler for around 12 technicians in our contact center (doing phone support).

View 5 Replies View Related

Multiple Solver Constraints In Solver

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

Solver Solver To Calculate Through VBA

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

Solver- When Solver "changes Cells"

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

IE Automation

Aug 3, 2009

I'm trying to do some automation of a website that has one of those annoying javascript popup dialog boxes you have to click OK on before you can progress. How can I kill that so that I don't have to manually click on "Ok" so that my macro can keep running?

View 9 Replies View Related

VBA Into IE Automation

Feb 20, 2010

You take an input, click a button. This will them create a small HTML table with a text input box and another button.

Sub VisitWebsite()
Dim ie As Object
Dim tcode As String
Dim sURL As String
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
sURL = http://sample.jsp
ie.navigate sURL
ie.Visible = True
tcode = "apples"

While ie.busy
DoEvents
Wend
Application.Wait Now() + TimeValue("00:00:03")

For Each ieForm In ie.document.forms
ieForm(1).Value = tcode
ieForm.submit
Set ieForm = Nothing
Exit For
Next
The code ieForm(1).Value = tcode works. The code ieForm.submit also hits submit on the button.

The problem is I cannnot figure out how to access the 2nd button which is generated when you click the 1st button. I have tried every variation of ieForm(1).Value. There appears to be only 3 forms (0, 1, 2). When I try 3 or greater, I get an error.

When I use ieForm(2).Value = "something", the Retrieve button text actually changes name to "something".

I've attached a screen shot of the webpage. I can insert text into the top Track Code box, and click Retrieve.

I can't change the text in the Routing Position field, and I cannot click the "Set" button. Any help would be greatly appreciated. I am still a beginner with VBA and it took me a while just to get it to work with the 1st input box.

View 9 Replies View Related

Regression Automation In Vba

Oct 2, 2008

The above is a screenshot of the data analysis (regression) I want to automate with vba code. Like all macros, I tried to record first and only got the following

View 3 Replies View Related

Email Automation

Feb 11, 2010

I am trying to create a document that automatically sends an email whenever a field reaches a certain value. I am pulling the data from different worksheets onto a summary worksheet and using the data on the summary sheet as the point at which my code checks to see whether the value is below the minimum required. The summary sheet updates automatically whenever I change the data in one of the other sheets but the email will not send automatically when the summary sheet is updated. When I run the macro individually the email sends, however I need some way of triggering it so that it sends automatically upon the data in the field changing. Can anyone help me with this?

Here is an example of some of the code I am using:


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D3"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value < 1 Then
ANDES1
End If
End If
If Not Application.Intersect(Range("E3"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value < 1 Then
ANDES2
End If
End If
End Sub

View 9 Replies View Related

Automation Error After Some Iterations?

Jun 11, 2014

Creating a spreadsheet to inventory cups each day. When a macro was invoked do the following:

-unprotect the worksheet

-cut/paste the completed sheet below the current

-bring in the values form the previous day's inventory

-set protection on new spreadsheet to lock the cells

-blank out old values

-reprotect the worksheet

Pretty straightforward and seems to work fine for a few iterations, then crashes with "Run-time error '-2147417848 (80010108)': Automation error. The object invoked has disconnected from its clients.".

As FYI, this code was mostly generated using a record macro session, so no variables involved.

Here is a screenshot of the spreadsheet as it sits now:

spreadsheet.png

Here is the code:
Sub NewDay()
'
' NewDay Macro

' Create new day and copy cup count from previous day[code]....

View 2 Replies View Related

Automation Of Creating PDF Files

Jun 24, 2009

We are trying to automate the creation of PDF files for each sheet in an Excel file,a nd keep getting error messages. Can someone help? It produces the post script file, but it has no data nd then doesn't create a PDf file at all. We have Excel 2003, and have the below code setup.

View 10 Replies View Related

Excel Automation - Timer?

Nov 5, 2009

I have a file that I update daily. It involves opening the file, going to a drop down menu and selecting 1 of the listed items and pressing a button to run the macro. Once the macro is complete, I then go back to the dropdown menu and select the next line item and press the same button to run the macro on this. I repeat this task 7times.

All the macro does is load a txt file to a third party system.

I am looking to see if it is possible to reduce the time it takes to do this task.

View 10 Replies View Related

VBA Automation - When To Use Display Alerts

Apr 18, 2012

Using VBA automation - set ObjXL as an Excel.Application
Lots of code and data transfer
then:

3410 ObjXL.ActiveWorkbook.SaveAs FileName:=strSaveAsFileName
3420 ObjXL.Visible = False
3430 ObjXL.Quit
Set Objxl= nothing

should the line be set : ObjXL.displayAlerts = True
- befor the objxl.Quit ?
- before the Objxl.ActiveWorkbook.SaveAs FileName:= aname
how to close the ObjXL with out orphaning a process.

OR???
ObjXL.ActiveWorkbook.Names.Add Name:="Data1", RefersToR1C1Local:=ObjXL.Range("A5").CurrentRegion
Will this line of code create a 2nd instance of Excel?

View 1 Replies View Related

Calculate Sumsq Through VBA For Some Automation

Nov 20, 2012

I am trying to calculate the sumsq throught VBA for some automation.

The formula to be entered is - =SUMSQ(K1025:K1358)/(COUNT(K1025:K1358)-COUNTIF(B1025:B1358,"0"))

Another thing is that the row numbers are variables, and not fixed in automation. Let's call them R1 and R2. So I need the range to be R1 to R2 in all the instances in the above formula.

View 1 Replies View Related

Internet Explorer Automation Using VBA

Feb 27, 2013

I want to automate few steps,

Step 1 : click on button in Internet explorer1(IE1) which inturn opens Internet explorer2(IE2).
Step 2 : in IE2 i want to enter some value in textbox and click in "go" button.

Managed to get step 1 some how, need to proceed futher with step 2 given above

Private Sub IE_Autiomation()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject("InternetExplorer.Application")

[Code] .........

View 4 Replies View Related

Internet Explorer Automation

Aug 3, 2013

I am trying to automate a website which I use for daily office related work. I am navigating the website, selecting some options and clicking on download button using vba code. When I click on download it opens a new internet page. Now I have to click one more hyperlink on that newly opened internet page. How to do that?

View 1 Replies View Related

UserForm - Automation Error

Aug 5, 2008

I created a UserForm (userform1) and added a label to it which essentially just says: "Pick a Colour"...

The other UF controls are added on the fly using the below code...however when I try to add the event to each button I get the Automation Error but I don't really understand how / why... the events are actually added to the VB project ok...

Private Sub UserForm_Initialize()
Dim NewButton As MSForms.CommandButton
Dim ws_i, line As Integer
Dim clr_str As String
For Each ws In ActiveWorkbook.Worksheets

I added a dummy routine for test purposes which is to be invoked on click of UF button control (I have tried placing this code in a standard module, within UF module etc to no avail):

Sub HIDE_WS(clr_id As Long)
MsgBox clr_id
End Sub

So to reiterate -- when I invoke the initialisation of the UF I get the following error:


Automation Error
The object invoked has disonnected from its clients

All events are added for each control.

If I remove the adding of the events I know the UF populates with the correct controls etc...

View 9 Replies View Related

Pivot Charts Automation

Sep 16, 2009

pivot chart automation. I have a tab that contains thousands of rows and it grows larger on a weekly basis. On this tab is 169 peices of hardware I manage. Each week 1 row of data is added to all 169 peices of hardware. The data from the main tab contains metrics I need to chart. However, I am in need of a way of selecting a specific peice of hardware and having the pivot charts update automatically. There will be 26 Charts and going through each chart and selecting the proper hardware is going to take far too long.

Is there any way i can select just 1 peices of hardware from the data tab and have it populate all of these charts?

View 9 Replies View Related

AddIn Automation Sequence

Aug 1, 2006

how to automate AddIns sequence when opening Excel? I have 5 different AddIn (xla) and I have to launch them in a specific order (after the menu Essbase is installed - with xll) cause I'm adding rows in that menu. Excel is launching my xla's in alphabetical order but before Essbase is installed.

View 5 Replies View Related

Macro Automation Even When Formats Change

Jun 4, 2014

I receive sales data from my wholesalers every month and I continually have to format them to fit the structure of our in-house database. I wanted to design a macro that would automate this process. However, in some months, the files are recieved in a format that is a bit different from the wholesaler's usual format.

Is there such thing as an initial "litmus" test where I could try running the macro and if it doesn't fit the usual structure, there's an error code and I could do it by hand?

View 3 Replies View Related

Excel Macros Email Automation

Mar 2, 2014

I am new to excel macros and writing automation code....I work for a company that sells special permits and so far i have written a macro to bring up a pop up box when a permit has expired but i also want to be alerted by email, how can I do this, also is there anyway to stop the macro from running once it finds all of the expired permits? I usually press ctrl + break....

I have attached the file to this post : Book1.xlsm‎

View 14 Replies View Related

Excel IE Automation - Read Web Table

Sep 24, 2010

I am trying to analyze a web page and would like to search through the contents of a web table. I need to extract text error messages which can be located at various unpredictable rows / columns in the web table.

How can I do this?

View 9 Replies View Related

Web Automation Tick Box In Nested Tables

Apr 16, 2013

My situation so far i have a rather large program in vba that accesses a site (confidential info im afriad will post snippets though) logs in navigates through a rabbit warren of pages using different types div's form's a href's etc and finally get to one page before where i need to extract information from!!

This webpage has one large table then nested tables within for each entry.

For example

PHP Code:

<table><tr><td><table>info....</table></tr></td><tr><td><table>info....
</table></tr></td><tr><td><table>info....</table></tr></td></table> 

I need to find a way to search the data cells within the nested tables find a specific displayed value then if required tick the checkbox (which has dynamically generated id's names etc) in that row then move on to the next table and do the same.

All I need to do is establish that one row has the data value i need and tick the check box that correlates (which is in the same row).

PHP Code:

<table border="0" cellpadding="0" cellspacing="0"> 
<tr class="altline"> <td> <table> <tr>  <td class="col_time" title="16/04/2013">18:30</td>                      
<td class="col_duration">00:51</td>   <td class="col_placetype"></td>     

[Code] ...........

View 4 Replies View Related

Copy / Paste Automation Macro

Jun 10, 2013

I am trying to automate the following task

The excel spreadsheet I have has data in cells A2, B2, C2, and D2. There are many rows one below the other. The data is as below:

A2 = Orange
B2 = New York
C2= Ferrari
D2= Summer

I need to copy the contents of A2, B2, D2 and D2 in an orderly manner on the second work sheet of the same work book as below:

On Second work sheet, Data should be only in column A and B as following with fixed titles

Fruit = Orange
City = New York
Car = Ferrari
Season = Summer

I want to keep doing this for all the rows which have data in them. Fruit, City , Car and Season will be the constant titles.

I recorded a macro, but it does the copy paste thing only for the first row.

Script that continues the process as long as there is data in the sheet1

View 1 Replies View Related

Excel / Access Report Automation

Sep 10, 2013

I have an Excel report that I'm wanting to know if it can be automated. Basically it starts off in Access, I have a few queries that run via an Access Macro, once the queries are done there is one query via the macro that exports a file of data to excel. I then have a 2nd excel file that is a pivot table that I refresh from the exported Excel file of data from Access. Once refershed, save it, upload it to a Sharepoint Site and send out an email via Outlook. Basically I'm wanting to know if this can be automated to were it runs at like 6am or something before I even get on my computer. I'm not a vba expert, I can do some basic stuff but what takes most people an hour or so to do would take me a day or so. Also would this be easier to just have the pivot update directly to the Access DB?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved