[Excel Solver issue] There is a different when run the macro whit or whitout a button

%3CLINGO-SUB%20id%3D%22lingo-sub-3497586%22%20slang%3D%22zh-CN%22%3E%5BExcel%20Solver%20issue%5D%20There%20is%20a%20different%20when%20run%20the%20macro%20whit%20or%20whitout%20a%20button%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3497586%22%20slang%3D%22zh-CN%22%3E%3CP%3EI%26nbsp%3B%20Add%20a%20sub%20and%20run%20it%20in%20Vbe%20or%20View-%26gt%3BMacros-%26gt%3BRun%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20test1()%0A%20%20%20%20SolverReset%0A%20%20%20%20SolverAdd%20CellRef%3A%3D%22%24a%241%22%2C%20Relation%3A%3D1%2C%20FormulaText%3A%3D%221%22%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20result%20is%20what%20i%20need%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dxq92_0-1655052728499.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_0-1655052728499.png%22%20style%3D%22width%3A%20385px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_0-1655052728499.png%22%20style%3D%22width%3A%20385px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_0-1655052728499.png%22%20style%3D%22width%3A%20385px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F379652iEC08D7E82742A98F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dxq92_0-1655052728499.png%22%20alt%3D%22dxq92_0-1655052728499.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20when%20i%20add%20a%20button%20to%20run%20the%20macro%2CThere%20is%20nothing%20.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dxq92_1-1655052780465.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_1-1655052780465.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_1-1655052780465.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_1-1655052780465.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F379653iDADB74492483BB88%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dxq92_1-1655052780465.png%22%20alt%3D%22dxq92_1-1655052780465.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eafter%20that%20i%20modify%201%20to%200.99%20and%20run%20it%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20test1()%0A%20%20%20%20SolverReset%0A%20%20%20%20SolverAdd%20CellRef%3A%3D%22%24a%241%22%2C%20Relation%3A%3D1%2C%20FormulaText%3A%3D%220.9999%22%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dxq92_2-1655052899239.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_2-1655052899239.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_2-1655052899239.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dxq92_2-1655052899239.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F379654iC2D46F0E584EDDDB%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dxq92_2-1655052899239.png%22%20alt%3D%22dxq92_2-1655052899239.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3497586%22%20slang%3D%22zh-CN%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20Solver%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3498848%22%20slang%3D%22zh-CN%22%3EReply%3A%20%5BExcel%20Solver%20issue%5D%20There%20is%20a%20different%20when%20run%20the%20macro%20whit%20or%20whitout%20a%20button%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3498848%22%20slang%3D%22zh-CN%22%3EIs%20there%20any%20one%20know%20how%20to%20deal%20it%3F%3C%2FLINGO-BODY%3E
New Contributor

I  Add a sub and run it in Vbe or View->Macros->Run

 

 

 

 

 

Sub test1()
    SolverReset
    SolverAdd CellRef:="$a$1", Relation:=1, FormulaText:="1"
End Sub

 

 

 

 

 

 

The result is what i need

dxq92_0-1655052728499.png

 

But when i add a button to run the macro,There is nothing .

dxq92_1-1655052780465.png

 

after that i modify 1 to 0.99 and run it again.

 

 

 

 

 

Sub test1()
    SolverReset
    SolverAdd CellRef:="$a$1", Relation:=1, FormulaText:="0.9999"
End Sub

 

 

 

 

 

dxq92_2-1655052899239.png

 

1 Reply