680 likes | 806 Views
11. Visual Basic Macro Recorder. Open Excel. Click File -> Save As. Save As a Excel Macro-Enabled Workbook. Click File -> Options. Click Customize Ribbon. Tick Developer. Click OK. Select Developer menu. Macro Recorder.
E N D
Macro Recorder • A job may require you to do the same repetitive task every day in Excel • You can make Excel complete some of these tasks automatically by recording a macro • All you have to do to repeat the action is to click a button
Formatting Cells • If you are creating tables of results you may need to format them in a particular way e.g. font, border, background • Rather than doing each step repeatedly we can record the actions once, and then make Excel repeat them
Every action we take from now on will be recorded until we click Stop Recording
Click Font and select Times New Roman,Bold, Size 14 and Colour Dark Blue
Excel has recorded all of the tasks which you have just completed, and written a program
You can make changes to this program by typing into the script
Press Ctrl + oThis is the shortcut key we assigned to our macro
The macro is run and all of the tasks are completed automatically
Challenge • Go into Visual Basic editor • Change the Font Name to “Verdana” • Change the Font Style to “Italic” • Change the Font Size to 12 • Save and Close the Visual Basic editor • Select the table again and press Ctrl+o to reformat the table
Trial and Error • The best way to learn specific commands in Visual Basic is to use the Macro Recorder • You can look at the code that is generated and then try to make some changes
Stock Screener • By using some creativity you can create complex programs using Visual Basic • In the following example we will download data from Yahoo Finance, and then filter it to find companies with a low P/E ratio
Type in the following web addresshttp://finance.yahoo.com/d/quotes.csv?s=MSFT+GOOG&f=snpryv