简体   繁体   中英

VBA - Trigger event with excel solver

I have found plenty of resources on how to start the excel solver with a macro. How about the other way around? Is there a possiblity to start a macro triggered by the execution of the excel solver?

I know that macros can be triggered for example through the change of values in cells. A workaround could be to go for a cell, which the solver will manipulate and start the macro whenever something changes there.

My goal is to automatically document the use of the solver within a worksheet, extracting information about the usage. For example through the SolverSolve and SolverGet functions.

Maybe something like this.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
        If IsNumeric(Target.Value) And Target.Value > 200 Then
            Call YourMacroName
        End If
    End If
End Sub

Of course you will NOT reprogram, or replace, Solver, in any way. There was a lot of brain power that went into creating it. Why reinvent the wheel?

http://ask.brothersoft.com/the-history-of-excel-solver-147811.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM