680 likes | 819 Vues
Learn how to streamline repetitive Excel tasks using the Visual Basic for Applications (VBA) Macro Recorder. By recording your actions, you can automate formatting, data manipulation, and other routine operations without performing each step manually. This guide walks you through creating a macro that formats tables, including changing font styles and sizes. You'll also discover how to modify the recorded VBA code in the Visual Basic editor to customize your macros further. Save time and enhance productivity by mastering Excel macros!
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