Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  CPLEX in Excel 2013 (VBA)

    Posted Tue October 29, 2013 05:55 PM

    Originally posted by: stella1980


    Hi,

    I'm trying to use CPLEX in Excel 2013 (on windows 7 x64). I added the file cplexvba.bas to my project and added the cplex add-in (.xll file).

    When trying to run one of the examples (example2.bas), everything seems to work fine until I get to CPXsolve. Then, the program seems to run indefinitely and the [Not Responding] warning ultimately appears. I then have to kill Excel to stop this from running and no solution is found.

    Also, I am not sure if this is normal, but after adding the cplex add-in, no additional buttons appear in the Data tab in Excel.

    Any help would be greatly appreciated.

    Thanks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX in Excel 2013 (VBA)

    Posted Wed October 30, 2013 04:56 AM

    What CPLEX version do you use?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX in Excel 2013 (VBA)

    Posted Wed October 30, 2013 08:41 AM

    Originally posted by: stella1980


    Hi Daniel,

    I use CPLEX 12.5.1 (x86). (The 64 bit version seems to give similar problem with Excel)

    Thanks


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX in Excel 2013 (VBA)

    Posted Thu October 31, 2013 04:38 AM

    So far I could not reproduce your problem here. Everything works fine. What I did was:

    1. Add the CPLEX Excel AddIn. It correctly appears in the 'Add-Ins' tab (nothing will appear in the Data tab).
    2. Opened the Visual Basic Editor and imported cplexvba.bas and examples2.bas.
    3. Ran the Example2() function.

    As expected, this solved the model and displayed the solution dialog. Did you do exactly the same or did you do something else?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: CPLEX in Excel 2013 (VBA)

    Posted Thu October 31, 2013 09:41 AM

    Originally posted by: stella1980


    You are right, the CPLEX add-in is present in the Add-ins tab. The steps I followed are exactly the same as you but the problem persists (even on the smaller example 'example1.bas'). I installed an older version of Excel (Excel 2007) to check if my add-in had a problem - same add-in works fine on this older version.

    Do you have any ideas?


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: CPLEX in Excel 2013 (VBA)

    Posted Thu October 31, 2013 09:53 AM

    Unfortunately, I have no idea what might be wrong. Excel2013 is not officially supported by the CPLEX Excel connector but I also do not see what could be the difference to older versions of Excel here.

    Do you have to run CPLEX from a spreadsheet? Or is it just enough to read data from a spreadsheet and maybe store the results in a spreadsheet. OPL allows reading from and writing to a spreadsheet. CPLEX also has a C# connector, so you could use C# to interact with Excel and use CPLEX's C# connector to do the optimization.

    If possible, I recommend doing one of the latter since the CPLEX Excel connector has been deprecated anyway (see here).


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: CPLEX in Excel 2013 (VBA)

    Posted Thu November 07, 2013 10:50 AM

    Originally posted by: stella1980


    Thank you very much for your response Daniel. I did not manage to make it work with Excel2013, so I followed you advice and wrote the code in C++. I then just call the resulting executable from Excel and that works well.


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: CPLEX in Excel 2013 (VBA)

    Posted Fri December 27, 2013 06:01 PM

    Originally posted by: m.dehghani86


    Hello Daniel

    Actually, I recently started to use CPLEX, I need use CPLEX to use in Arena Rockwell (simulation software), but I have no idea how can I start? I read CPLEX manual but I couldn't use CPLEX. I cannot even add CPLEX to Excel. I found CPLEX xll file but I can not add it to excel as add-in. I'm totally lost. is there any video or manual which describes combination of VBA and CPLEX step b step? 

    thanks

     

    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: CPLEX in Excel 2013 (VBA)

    Posted Mon January 06, 2014 05:44 AM


  • 10.  Re: CPLEX in Excel 2013 (VBA)

    Posted Mon January 06, 2014 09:41 AM

    Originally posted by: m.dehghani86


    Yes, I did, I followed the steps carefully, but it doesn't work

    my windows is 64 bit and I'm using Excel 2010, I think CPLEX doesnt work with 64bit excel ? 

    I can not add CPLEX xll file as add in to excel, also, when I add cplexvba.bas to VBA, it can not recognize the modules. for example when I want to run CPLEX provided "example 1" it gives me error 1004. I attached the picture, please see the attachments

    thank you Daniel

     


    #CPLEXOptimizers
    #DecisionOptimization