I recently purchased a book, Excel for Scientists and Engineers: Numerical Methods by E. Joseph Billo. I am trying to learn VBA and ways to apply it to expanding Excel's capabilities to help with some of our scientific calculations and data at work. After working on some of the spreadsheet examples, I get the following Microsoft Visual Basic error everytime I open Excel: Run-time error '1004': Method 'MacroOptions' of object'_Application' failed. When I click debug it shows the following code highlighted:
Application.MacroOptions Macro:="MIDENT", Category:="NumericalMethods Toolbox", _
Description:="Creates an identity matrix of a specified size. The size argument is optional." _
& Chr(13) & "Maximum allowable size is 63 x 63; larger gives #VALUE! error." _
& Chr(13) & "Can be used in a formula or used to fill a selection."
I have included the rest of the code. Can someone tell me what I need to do to fix this error? Thanks.
Private Sub Workbook_Open()
If ThisWorkbook.IsAddin = True Then
ThisWorkbook.Activate
ActiveWindow.Visible = True
End If
Application.MacroOptions Macro:="MIDENT", Category:="NumericalMethods Toolbox", _
Description:="Creates an identity matrix of a specified size. The size argument is optional." _
& Chr(13) & "Maximum allowable size is 63 x 63; larger gives #VALUE! error." _
& Chr(13) & "Can be used in a formula or used to fill a selection."
Application.MacroOptions Macro:="MINDEX", Category:="NumericalMethods Toolbox", _
Description:="Returns a horizontal 2-element array containing the row and column numbers" _
& Chr(13) & "of a specified value in an array. match_type is the number –1, 0, or 1." _
& Chr(13) & "0 returns the location of the value that is equal to lookup_value, or #N/A."
Application.MacroOptions Macro:="MSCALE", Category:="NumericalMethods Toolbox", _
Description:="Calculates scale factors for a NxM matrix and returns a NxM scaled matrix." _
& Chr(13) & "All values in a row are scaled by dividing by the largest element in that row." _
& Chr(13) & "If scale_factor_logical = TRUE, returns 1-column vector of scale factors."
Application.MacroOptions Macro:="Arr", Category:="NumericalMethods Toolbox", _
Description:="Combines individual 1-D or 2-D arrays into a 2-D array." _
& Chr(13) & "All individual arrays must be vertical." _
& Chr(13) & "All individual arrays must have same number of rows."
Application.MacroOptions Macro:="InterpL", Category:="NumericalMethods Toolbox", _
Description:="Performs linear interpolation, using an array of known_x´s, known_y´s." _
& Chr(13) & "The known_x´s must be in ascending order."
Application.MacroOptions Macro:="InterpC", Category:="NumericalMethods Toolbox", _
Description:="Performs cubic interpolation, using an array of known_x´s, known_y´s." _
& Chr(13) & "The known_x´s must be in ascending order."
Application.MacroOptions Macro:="InterpC2", Category:="NumericalMethods Toolbox", _
Description:="Performs cubic interpolation in a two-way table, using an array of known_x´s, known_y´s and known_z's" _
& Chr(13) & "known_x´s are in a column, known_y´s are in a row, or vice versa." _
& Chr(13) & "The known_x´s and known_y´s must be in ascending order."
Application.MacroOptions Macro:="dydx", Category:="NumericalMethods Toolbox", _
Description:="Returns the first derivative of a cell formula F(x)." _
& Chr(13) & "expression is F(x), variable is x." _
& Chr(13) & "scale_factor is used to handle the case where x = 0."
Application.MacroOptions Macro:="d2ydx2", Category:="NumericalMethods Toolbox", _
Description:="Returns the second derivative of a cell formula F(x)." _
& Chr(13) & "expression is F(x), variable is x." _
& Chr(13) & "scale_factor is used to handle the case where x = 0."
Application.MacroOptions Macro:="IntegrateT", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using simple trapezoidal area calculation." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="IntegrateS", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using Simpson's 1/3 rule area calculation." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="Integrate", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using ten-point Gauss-Legendre quadrature formula." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="NewtRaph", Category:="NumericalMethods Toolbox", _
Description:="Returns a root of a function by the Newton-Raphson method." _
& Chr(13) & "expression is a reference to a cell formula; variable is a cell reference." _
& Chr(13) & "initial_value can be a number, reference or omitted."
Application.MacroOptions Macro:="GoalSeek", Category:="NumericalMethods Toolbox", _
Description:="Finds value of changing_cell to make target_cell have a desired value." _
& Chr(13) & "changing_cell is a reference to a cell formula; target_cell is a cell reference." _
& Chr(13) & "objective_value can be a number or reference."
Application.MacroOptions Macro:="Bairstow", Category:="NumericalMethods Toolbox", _
Description:="Returns the coefficients of a regular polynomial (maximum order = 6)." _
& Chr(13) & "equation is a reference to a formula in a cell" _
& Chr(13) & "reference is a cell reference or a name."
Application.MacroOptions Macro:="GaussElim", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by Gaussian Elimination." _
& Chr(13) & "Returns the solution vector as an array." _
& Chr(13) & "Selected range can be either horizontal or vertical."
Application.MacroOptions Macro:="GaussJordan1", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Jordan elimination method." _
& Chr(13) & "Returns a single element of the solution vector, specified by value_index."
Application.MacroOptions Macro:="GaussJordan2", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Jordan elimination method." _
& Chr(13) & "Returns the solution vector as an array."
Application.MacroOptions Macro:="GaussSeidel", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Seidel method." _
& Chr(13) & "Coefficients matrix cannot have zero diagonal element."
Application.MacroOptions Macro:="GaussSeidel2", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Seidel method." _
& Chr(13) & "This version attempts to include swapping if diagonal element = 0."
Application.MacroOptions Macro:="SimultEqNL", Category:="NumericalMethods Toolbox", _
Description:="Finds roots of nonlinear simultaneous equations by Newton iteration method."
Application.MacroOptions Macro:="Runge1", Category:="NumericalMethods Toolbox", _
Description:="Solves an ODE y'=F(x,y) by 4th-order Runge-Kutta method." _
& Chr(13) & "x_variable is a reference to x, y_variable is a reference to y." _
& Chr(13) & "deriv_formula is a reference to the derivative dy/dx." _
& Chr(13) & "interval is a reference to delta x"
Application.MacroOptions Macro:="Runge3", Category:="NumericalMethods Toolbox", _
Description:="Solves a system of N simultaneous first-order ODE's by 4th-order RK method." _
& Chr(13) & "x_variable is a reference to x, y_variables is a reference to y(1) ... y(N)." _
& Chr(13) & "deriv_formulas is a reference to the derivatives dy/dx, in same order." _
'& Chr(13) & "interval is a reference to delta x. 'index specifies the y(i) to be returned. If omitted, returns the array."
If ActiveWindow.Visible = True Then ActiveWindow.Visible = False
End Sub
Application.MacroOptions Macro:="MIDENT", Category:="NumericalMethods Toolbox", _
Description:="Creates an identity matrix of a specified size. The size argument is optional." _
& Chr(13) & "Maximum allowable size is 63 x 63; larger gives #VALUE! error." _
& Chr(13) & "Can be used in a formula or used to fill a selection."
I have included the rest of the code. Can someone tell me what I need to do to fix this error? Thanks.
Private Sub Workbook_Open()
If ThisWorkbook.IsAddin = True Then
ThisWorkbook.Activate
ActiveWindow.Visible = True
End If
Application.MacroOptions Macro:="MIDENT", Category:="NumericalMethods Toolbox", _
Description:="Creates an identity matrix of a specified size. The size argument is optional." _
& Chr(13) & "Maximum allowable size is 63 x 63; larger gives #VALUE! error." _
& Chr(13) & "Can be used in a formula or used to fill a selection."
Application.MacroOptions Macro:="MINDEX", Category:="NumericalMethods Toolbox", _
Description:="Returns a horizontal 2-element array containing the row and column numbers" _
& Chr(13) & "of a specified value in an array. match_type is the number –1, 0, or 1." _
& Chr(13) & "0 returns the location of the value that is equal to lookup_value, or #N/A."
Application.MacroOptions Macro:="MSCALE", Category:="NumericalMethods Toolbox", _
Description:="Calculates scale factors for a NxM matrix and returns a NxM scaled matrix." _
& Chr(13) & "All values in a row are scaled by dividing by the largest element in that row." _
& Chr(13) & "If scale_factor_logical = TRUE, returns 1-column vector of scale factors."
Application.MacroOptions Macro:="Arr", Category:="NumericalMethods Toolbox", _
Description:="Combines individual 1-D or 2-D arrays into a 2-D array." _
& Chr(13) & "All individual arrays must be vertical." _
& Chr(13) & "All individual arrays must have same number of rows."
Application.MacroOptions Macro:="InterpL", Category:="NumericalMethods Toolbox", _
Description:="Performs linear interpolation, using an array of known_x´s, known_y´s." _
& Chr(13) & "The known_x´s must be in ascending order."
Application.MacroOptions Macro:="InterpC", Category:="NumericalMethods Toolbox", _
Description:="Performs cubic interpolation, using an array of known_x´s, known_y´s." _
& Chr(13) & "The known_x´s must be in ascending order."
Application.MacroOptions Macro:="InterpC2", Category:="NumericalMethods Toolbox", _
Description:="Performs cubic interpolation in a two-way table, using an array of known_x´s, known_y´s and known_z's" _
& Chr(13) & "known_x´s are in a column, known_y´s are in a row, or vice versa." _
& Chr(13) & "The known_x´s and known_y´s must be in ascending order."
Application.MacroOptions Macro:="dydx", Category:="NumericalMethods Toolbox", _
Description:="Returns the first derivative of a cell formula F(x)." _
& Chr(13) & "expression is F(x), variable is x." _
& Chr(13) & "scale_factor is used to handle the case where x = 0."
Application.MacroOptions Macro:="d2ydx2", Category:="NumericalMethods Toolbox", _
Description:="Returns the second derivative of a cell formula F(x)." _
& Chr(13) & "expression is F(x), variable is x." _
& Chr(13) & "scale_factor is used to handle the case where x = 0."
Application.MacroOptions Macro:="IntegrateT", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using simple trapezoidal area calculation." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="IntegrateS", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using Simpson's 1/3 rule area calculation." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="Integrate", Category:="NumericalMethods Toolbox", _
Description:="Integrates F(x) over a specified range, using ten-point Gauss-Legendre quadrature formula." _
& Chr(13) & "expression is F(x), variable is x."
Application.MacroOptions Macro:="NewtRaph", Category:="NumericalMethods Toolbox", _
Description:="Returns a root of a function by the Newton-Raphson method." _
& Chr(13) & "expression is a reference to a cell formula; variable is a cell reference." _
& Chr(13) & "initial_value can be a number, reference or omitted."
Application.MacroOptions Macro:="GoalSeek", Category:="NumericalMethods Toolbox", _
Description:="Finds value of changing_cell to make target_cell have a desired value." _
& Chr(13) & "changing_cell is a reference to a cell formula; target_cell is a cell reference." _
& Chr(13) & "objective_value can be a number or reference."
Application.MacroOptions Macro:="Bairstow", Category:="NumericalMethods Toolbox", _
Description:="Returns the coefficients of a regular polynomial (maximum order = 6)." _
& Chr(13) & "equation is a reference to a formula in a cell" _
& Chr(13) & "reference is a cell reference or a name."
Application.MacroOptions Macro:="GaussElim", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by Gaussian Elimination." _
& Chr(13) & "Returns the solution vector as an array." _
& Chr(13) & "Selected range can be either horizontal or vertical."
Application.MacroOptions Macro:="GaussJordan1", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Jordan elimination method." _
& Chr(13) & "Returns a single element of the solution vector, specified by value_index."
Application.MacroOptions Macro:="GaussJordan2", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Jordan elimination method." _
& Chr(13) & "Returns the solution vector as an array."
Application.MacroOptions Macro:="GaussSeidel", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Seidel method." _
& Chr(13) & "Coefficients matrix cannot have zero diagonal element."
Application.MacroOptions Macro:="GaussSeidel2", Category:="NumericalMethods Toolbox", _
Description:="Solves systems of linear equations by the Gauss-Seidel method." _
& Chr(13) & "This version attempts to include swapping if diagonal element = 0."
Application.MacroOptions Macro:="SimultEqNL", Category:="NumericalMethods Toolbox", _
Description:="Finds roots of nonlinear simultaneous equations by Newton iteration method."
Application.MacroOptions Macro:="Runge1", Category:="NumericalMethods Toolbox", _
Description:="Solves an ODE y'=F(x,y) by 4th-order Runge-Kutta method." _
& Chr(13) & "x_variable is a reference to x, y_variable is a reference to y." _
& Chr(13) & "deriv_formula is a reference to the derivative dy/dx." _
& Chr(13) & "interval is a reference to delta x"
Application.MacroOptions Macro:="Runge3", Category:="NumericalMethods Toolbox", _
Description:="Solves a system of N simultaneous first-order ODE's by 4th-order RK method." _
& Chr(13) & "x_variable is a reference to x, y_variables is a reference to y(1) ... y(N)." _
& Chr(13) & "deriv_formulas is a reference to the derivatives dy/dx, in same order." _
'& Chr(13) & "interval is a reference to delta x. 'index specifies the y(i) to be returned. If omitted, returns the array."
If ActiveWindow.Visible = True Then ActiveWindow.Visible = False
End Sub