简体   繁体   English

VBA-使用Excel求解器触发事件

[英]VBA - Trigger event with excel solver

I have found plenty of resources on how to start the excel solver with a macro. 我已经找到了很多有关如何使用宏启动excel solver的资源。 How about the other way around? 反过来呢? Is there a possiblity to start a macro triggered by the execution of the excel solver? 是否有可能启动由excel解算器执行触发的宏?

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. 例如,通过SolverSolveSolverGet函数。

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 http://ask.brothersoft.com/the-history-of-excel-solver-147811.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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