<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//TaxonX//DTD Taxonomic Treatment Publishing DTD v0 20100105//EN" "../../nlm/tax-treatment-NS0.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tp="http://www.plazi.org/taxpub" article-type="research-article">
  <front>
    <journal-meta>
      <journal-id journal-id-type="publisher-id">17</journal-id>
      <journal-id journal-id-type="index">urn:lsid:arphahub.com:pub:8E638694-B4E0-570A-856A-746FF325BF6B</journal-id>
      <journal-title-group>
        <journal-title xml:lang="en">Research Ideas and Outcomes</journal-title>
        <abbrev-journal-title xml:lang="en">RIO</abbrev-journal-title>
      </journal-title-group>
      <issn pub-type="epub">2367-7163</issn>
      <publisher>
        <publisher-name>Pensoft Publishers</publisher-name>
      </publisher>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.3897/rio.8.e79006</article-id>
      <article-id pub-id-type="publisher-id">79006</article-id>
      <article-id pub-id-type="manuscript">18454</article-id>
      <article-categories>
        <subj-group subj-group-type="heading">
          <subject>Research Idea</subject>
        </subj-group>
        <subj-group subj-group-type="sdg">
          <subject>Industry</subject>
          <subject> innovation &amp;amp; infrastructure</subject>
        </subj-group>
      </article-categories>
      <title-group>
        <article-title>Use of Worksheet events in Excel to save solver objective cell value from each iteration</article-title>
      </title-group>
      <contrib-group content-type="authors">
        <contrib contrib-type="author" corresp="yes">
          <name name-style="western">
            <surname>Sambaraju</surname>
            <given-names>Prasanth</given-names>
          </name>
          <email xlink:type="simple">prashanth.kng1@gmail.com</email>
          <xref ref-type="aff" rid="A1">1</xref>
        </contrib>
      </contrib-group>
      <aff id="A1">
        <label>1</label>
        <addr-line content-type="verbatim">Independent Researcher, Hyderabad, India</addr-line>
        <institution>Independent Researcher</institution>
        <addr-line content-type="city">Hyderabad</addr-line>
        <country>India</country>
      </aff>
      <author-notes>
        <fn fn-type="corresp">
          <p>Corresponding author: Prasanth Sambaraju (<email xlink:type="simple">prashanth.kng1@gmail.com</email>).</p>
        </fn>
        <fn fn-type="edited-by">
          <p>Academic editor: Editorial Secretary</p>
        </fn>
      </author-notes>
      <pub-date pub-type="collection">
        <year>2022</year>
      </pub-date>
      <pub-date pub-type="epub">
        <day>25</day>
        <month>02</month>
        <year>2022</year>
      </pub-date>
      <volume>8</volume>
      <elocation-id>e79006</elocation-id>
      <uri content-type="arpha" xlink:href="http://openbiodiv.net/6C920754-535B-5449-901A-8BAB854E9E57">6C920754-535B-5449-901A-8BAB854E9E57</uri>
      <uri content-type="zenodo_dep_id" xlink:href="https://zenodo.org/record/10411472">10411472</uri>
      <history>
        <date date-type="received">
          <day>07</day>
          <month>12</month>
          <year>2021</year>
        </date>
        <date date-type="accepted">
          <day>22</day>
          <month>02</month>
          <year>2022</year>
        </date>
      </history>
      <permissions>
        <copyright-statement>Prasanth Sambaraju</copyright-statement>
        <license license-type="creative-commons-attribution" xlink:href="http://creativecommons.org/licenses/by/4.0/" xlink:type="simple">
          <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.</license-p>
        </license>
      </permissions>
      <abstract>
        <label>Abstract</label>
        <p>Solver is a Microsoft Excel add-in program which is used to find an optimal value for a formula in the objective cell. Solver accomplishes this either by maximizing, minimizing or setting the objective cell value to a specific value. The article presents the utility of in built worksheet events in Excel VBA to save the value of objective cell from each iteration when solver is used for optimization.</p>
      </abstract>
      <kwd-group>
        <label>Keywords</label>
        <kwd>Solver</kwd>
        <kwd>Worksheet events</kwd>
        <kwd>Iteration</kwd>
      </kwd-group>
      <counts>
        <fig-count count="5"/>
        <table-count count="1"/>
        <ref-count count="3"/>
      </counts>
    </article-meta>
  </front>
  <body>
    <sec sec-type="Introduction">
      <title>Introduction</title>
      <p>Solver has been used in numerous and diverse applications (<xref ref-type="bibr" rid="B7556992">Kemmer and Keller 2010</xref>) and is ideally suited to fit data with non-linear functions by iterative algorithm. The algorithm works by minimizing the sum of the squared differences between the observed data points and the function describing the data (<xref ref-type="bibr" rid="B7554706">Brown 2001</xref>).</p>
    </sec>
    <sec sec-type="Methods">
      <title>Methods</title>
      <p>Biochemical oxygen demand (BOD) is used as measure of the pollution produced by domestic and industrial wastes. The data shown in Table <xref ref-type="table" rid="T7552412">1</xref> shows BOD data over a range of incubation days (<xref ref-type="bibr" rid="B7557001">Box et al. 2005</xref>). Data was fitted into the following model.</p>
      <p><tex-math id="M1">\documentclass[12pt]{standalone}
\usepackage{varwidth}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath, amssymb, graphics, setspace}
\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}
\newcounter{mathematicapage}
\begin{document}
   \begin{varwidth}{50in}
        \begin{equation*}
            Y = {b_1*(1-exp{(-b_2*x)})}
        \end{equation*}
    \end{varwidth}
\end{document}
</tex-math> (1)</p>
      <p>Y is the exponential model describing BOD</p>
      <p>b<sub>2</sub> is the rate constant (parameter 1)</p>
      <p>b<sub>1</sub> is the BOD value (parameter 2)</p>
      <p>x is incubation time in days</p>
    </sec>
    <sec sec-type="Solver Implementation">
      <title>Solver Implementation</title>
      <p>a) Data is entered in Excel, incubation days (x) in column A and BOD values (y) in column B.</p>
      <p>b) Initial values for b<sub>1</sub> and b<sub>2</sub> are set to 100 and 0.75 in cells F2 and F3.</p>
      <p>c) Y calculated was obtained by substituting b<sub>1</sub>, b<sub>2</sub> and corresponding x values in equation (1).</p>
      <p>d) Sum of squared errors (SSE) was obtained by squaring the difference between Yobs and Ycalc.</p>
      <p>e) Open Solver (In Excel 2013 it is located Data tab). The dialogue box is shown in Fig. <xref ref-type="fig" rid="F7552415">1</xref>.</p>
      <p>f) Solver also option of showing the iteration results (Refer to Fig. <xref ref-type="fig" rid="F7552419">2</xref>,click options in solver dialogue box). The detailed explanation for controlling solver features are described (<xref ref-type="bibr" rid="B7554706">Brown 2001</xref>).</p>
      <p>g) When the show iteration results is selected the following message is displayed, it prompts the user either to continue, stop or save scenario (Refer Fig. <xref ref-type="fig" rid="F7552423">3</xref>).</p>
      <p>h) The user has to manually select an option to show results of each iteration. This would considerably increase the time for reaching an optimal solution.</p>
      <p>i) The results obtained for parameters b<sub>1</sub>, b<sub>2</sub> and SSE after solver implementation matched with the reported values (<xref ref-type="bibr" rid="B7557001">Box et al. 2005</xref>).</p>
    </sec>
    <sec sec-type="Excel VBA to get result from each iteration">
      <title>Excel VBA to get result from each iteration</title>
      <p>The worksheet change event macro (as shown in Fig. <xref ref-type="fig" rid="F7552427">4</xref>) is triggered, when the value in either cells F2 or F3 changes, then these values are copied and are pasted in columns J (b<sub>1</sub>), K (b<sub>2</sub>) and L (SSE) respectively. The values of b<sub>1</sub>, b<sub>2</sub> (top) and SSE (bottom) for each iteration during the solver optimization are plotted in Fig. <xref ref-type="fig" rid="F7552431">5</xref>. The Excel macro file is included in Suppl. material <xref ref-type="supplementary-material" rid="S7554705">1</xref></p>
    </sec>
    <sec sec-type="Conclusion">
      <title>Conclusion</title>
      <p>This article demonstrates the use of Excel worksheet events to obtain the objective cell values after each iteration. The number of objective cell values obtained is dependent on the constraint precision value.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <title>References</title>
      <ref id="B7557001">
        <element-citation publication-type="book">
          <person-group person-group-type="author">
            <name name-style="western">
              <surname>Box</surname>
              <given-names>George E. P.</given-names>
            </name>
            <name name-style="western">
              <surname>Hunter</surname>
              <given-names>J. Stuart</given-names>
            </name>
            <name name-style="western">
              <surname>Hunter</surname>
              <given-names>William G.</given-names>
            </name>
          </person-group>
          <year>2005</year>
          <source>Statistics for Experimenters: Design, Innovation, and Discovery</source>
          <edition>Second</edition>
          <publisher-name>Wiley</publisher-name>
        </element-citation>
      </ref>
      <ref id="B7554706">
        <element-citation publication-type="article">
          <person-group person-group-type="author">
            <name name-style="western">
              <surname>Brown</surname>
              <given-names>Angus M</given-names>
            </name>
          </person-group>
          <year>2001</year>
          <article-title>A step-by-step guide to non-linear regression analysis of experimental data using a Microsoft Excel spreadsheet</article-title>
          <source>Computer Methods and Programs in Biomedicine</source>
          <volume>65</volume>
          <issue>3</issue>
          <fpage>191</fpage>
          <lpage>200</lpage>
          <comment content-type="language">English</comment>
          <pub-id pub-id-type="doi">10.1016/s0169-2607(00)00124-3</pub-id>
        </element-citation>
      </ref>
      <ref id="B7556992">
        <element-citation publication-type="article">
          <person-group person-group-type="author">
            <name name-style="western">
              <surname>Kemmer</surname>
              <given-names>Gerdi</given-names>
            </name>
            <name name-style="western">
              <surname>Keller</surname>
              <given-names>Sandro</given-names>
            </name>
          </person-group>
          <year>2010</year>
          <article-title>Nonlinear least-squares data fitting in Excel spreadsheets</article-title>
          <source>Nature Protocols</source>
          <volume>5</volume>
          <issue>2</issue>
          <fpage>267</fpage>
          <lpage>281</lpage>
          <pub-id pub-id-type="doi">10.1038/nprot.2009.182</pub-id>
        </element-citation>
      </ref>
    </ref-list>
  </back>
  <floats-group>
    <fig id="F7552415" position="float" orientation="portrait">
      <object-id content-type="arpha">767887AE-B4C6-5888-9A02-CBB8AF9ADE2A</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.figure1</object-id>
      <object-id content-type="zenodo_dep_id">6355752</object-id>
      <label>Figure 1.</label>
      <caption>
        <p>Solver implementation: Objective cell in F4 (minimize sum of squared errors) by changing values of b<sub>1</sub> and b<sub>2</sub> in cells F2 and F3 respectively.</p>
      </caption>
      <graphic xlink:href="rio-08-e79006-g001.jpg" position="float" id="oo_610759.jpg" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/fig/610759</uri>
      </graphic>
    </fig>
    <fig id="F7552419" position="float" orientation="portrait">
      <object-id content-type="arpha">5AA349DC-8A88-5F2A-B54E-D707FF475385</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.figure2</object-id>
      <object-id content-type="zenodo_dep_id">0</object-id>
      <label>Figure 2.</label>
      <caption>
        <p>Solver options tab.</p>
      </caption>
      <graphic xlink:href="rio-08-e79006-g002.jpg" position="float" id="oo_610760.jpg" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/fig/610760</uri>
      </graphic>
    </fig>
    <fig id="F7552423" position="float" orientation="portrait">
      <object-id content-type="arpha">9989C6EF-9942-5FB8-BB81-0E07B299D6AE</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.figure3</object-id>
      <object-id content-type="zenodo_dep_id">0</object-id>
      <label>Figure 3.</label>
      <caption>
        <p>Solver message box showing iteration result message.</p>
      </caption>
      <graphic xlink:href="rio-08-e79006-g003.jpg" position="float" id="oo_610761.jpg" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/fig/610761</uri>
      </graphic>
    </fig>
    <fig id="F7552427" position="float" orientation="portrait">
      <object-id content-type="arpha">AC95F0D8-9416-50B4-A0E2-5D0147AE9963</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.figure4</object-id>
      <object-id content-type="zenodo_dep_id">0</object-id>
      <label>Figure 4.</label>
      <caption>
        <p>Excel Worksheet Change event macro to copy result from each solver iteration.</p>
      </caption>
      <graphic xlink:href="rio-08-e79006-g004.jpg" position="float" id="oo_610762.jpg" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/fig/610762</uri>
      </graphic>
    </fig>
    <fig id="F7552431" position="float" orientation="portrait">
      <object-id content-type="arpha">C5710BE0-5FAB-5E25-9ADC-5B5986D9252C</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.figure5</object-id>
      <object-id content-type="zenodo_dep_id">6355764</object-id>
      <label>Figure 5.</label>
      <caption>
        <p>Plot showing the values of b<sub>1</sub>, b<sub>2</sub> (top) and SSE (bottom) for each iteration during the solver optimization.</p>
      </caption>
      <graphic xlink:href="rio-08-e79006-g005.jpg" position="float" id="oo_610763.jpg" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/fig/610763</uri>
      </graphic>
    </fig>
    <table-wrap id="T7552412" position="float" orientation="portrait">
      <label>Table 1.</label>
      <caption>
        <p>BOD Data.</p>
      </caption>
      <table rules="all" border="1">
        <tbody>
          <tr>
            <td rowspan="1" colspan="1">Incubation x (days)</td>
            <td rowspan="1" colspan="1">BOD (mg/L) y</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">1</td>
            <td rowspan="1" colspan="1">109</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">2</td>
            <td rowspan="1" colspan="1">149</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">3</td>
            <td rowspan="1" colspan="1">149</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">5</td>
            <td rowspan="1" colspan="1">191</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">7</td>
            <td rowspan="1" colspan="1">213</td>
          </tr>
          <tr>
            <td rowspan="1" colspan="1">10</td>
            <td rowspan="1" colspan="1">224</td>
          </tr>
        </tbody>
      </table>
    </table-wrap>
    <supplementary-material id="S7554705" orientation="portrait" position="float" xlink:type="simple">
      <object-id content-type="arpha">914F7ACD-0E3D-519A-9DFD-7AB4D8D82B08</object-id>
      <object-id content-type="doi">10.3897/rio.8.e79006.suppl1</object-id>
      <object-id content-type="zenodo_dep_id">6355742</object-id>
      <label>Supplementary material 1</label>
      <caption>
        <p>BOD data</p>
      </caption>
      <statement content-type="dataType">
        <label>Data type</label>
        <p>Excel macro enabled file</p>
      </statement>
      <statement content-type="notes">
        <label>Brief description</label>
        <p>BOD data and macro to save each objective cell value during solver implementation.</p>
      </statement>
      <p>File: oo_610765.xlsm</p>
      <media xlink:href="rio-08-e79006-s001.xlsm" mimetype="xlsm file" mime-subtype="xlsm" position="float" orientation="portrait" xlink:type="simple">
        <uri content-type="original_file">https://binary.pensoft.net/file/610765</uri>
      </media>
      <attrib specific-use="authors">Prasanth Sambaraju</attrib>
    </supplementary-material>
  </floats-group>
</article>
