VBA Primer: Brief on VBA Programming – Excel in Office 2013

R. Russell Rhinehart · 2016

A.1 To Start• Open an Excel Worksheet (and save it).• Set Macro Security Setting to Medium.Click on the Office Button in the upper left of the menu bar, Excel Options button in bottom of window, Trust Center in the left-hand menu, Trust Center Settings in the middle right of the window, and choose your security preference ("disable with notification", probably).Click OK.• Press ALT-F11 to open the VBA editor.Alternately, use the "Launch VBA" icon on the Developer Toolbar.(To install the Developer Toolbar, click on the "Office Button" (upper left), click on "Excel Options" (lower border of the new window), in the "Popular" set, check the "Show Developer Tab in the Ribbon" box.Close the "Office Button" window and you should see the "Developer" tab on the upper ribbon.)• In the new open window "VBA Editor" you should see three windows (Project, Properties,and Immediate) and a grayed space for another window.If the "Project" window does not appear, use the "View" menu item to add "Project Explorer".• Right-click in the Project window, then click on "Insert" and then "Module".This will open a window in the grayed space for writing the VBA code.Alternately, you can double-click on the spreadsheet name in the Project window to open a code window.Either way allows you to write VBA code.However, code in a code window attached to a spreadsheet (for instance, "Sheet1") can only interface with that sheet.• There are two categories of code -subroutine and function -with attributes similar to that of any language.To create a subroutine, type "SUB", spacebar, subname, and "()".For example, "Sub Practice()".Then hit Enter and "End Sub" will appear.Your code goes in between these two lines.To create a function, type "FUNCTION", spacebar, functionname, "(", argument list, and")".For example, "Function F_Multiply(x,y)".Then hit enter and Nonlinear Regression Modeling for Engineering Applications: Modeling, Model Validation, and Enabling Design of Experiments, First Edition.R. Russell Rhinehart.

Read the paper · More papers on PaperTik