4. Excel Macro-Enabled Workbook Structure

Your Excel workbook should contain the following sheets:

Sheet NamePurpose
ControlRun Forecast, View Models, Insert Charts, and Settings Buttons
InputTime series data
ConstraintsEquality or Inequality constraints

4a. VBA Button Wiring

Create a VBA module in Excel (Alt + F11 > Insert > Module) and paste the following and save (see Figure 9)

Sub RunMacroFrameForecast()

RunPython "import mf_excel. excel_client. addin as a; a. run_forecast_button()"
End Sub

Sub ViewMacroFrameModels()

RunPython "import mf_excel. excel_client. addin as a; a. view_models_button()"
End Sub

Sub InsertMacroFrameCharts ()

RunPython "import mf_excel. excel_client. addin as a; a. insert_charts_button()"
End Sub

Sub OpenMacroFrameSettings()

RunPython "import mf_excel. excel_client. addin as a; a. settings_button()"
End Sub
Figure 9: VBA editor
Figure 9

4b. Assigning Buttons in Excel Control Sheet

  1. Navigate to the Developer tab > Insert > Form Controls > Button (see Figure 10)
  2. Draw a button and assign appropriate names (Run Forecast, View Models, Insert Charts, Settings) (see Figure 11).
  3. Right-click each button > Assign Macro and choose the corresponding macro (see Figure 11).
Figure 10: Excel Developer tab
Figure 10
Figure 11: Assign Macro dialog
Figure 11