How to automate solver using loop function

Copper Contributor

Hi all, I try to use Solver in Microsoft Excel 365 to match the total molecular weight with linear combination of molecular weight of components. Since I have total 1000 rows, and I need to use Solver for each row, I want to know how could I use For loop or other options to automate Solver in Excel. My VBA code for single run of Solver ($AT$9 only) is below:

 

 

 

mengzy_0-1683659914508.png

 

And my Excel work sheet snapshot is below

mengzy_1-1683658587147.png

 

I try to use the following VBA code to automate but failed.

mengzy_1-1683661067622.png

 

 

 

 

How could I do this automatically from $AT$9 to $AT$1008? I am a newbie on VBA, and find the learning curve quite steep for myself. Thanks for your help!

Zhiyong

0 Replies