0% found this document useful (0 votes)
5 views11 pages

1. Your First Macro

This document provides an introduction to macros and the Visual Basic Editor (VBE) in Excel, including steps to record a macro, differences between relative and absolute recording, and how to run macros. It also includes instructions for fine-tuning settings on both Windows and Mac, as well as ways to run macros using various methods. The content is aimed at helping users become familiar with macro functionality and the VBE interface.

Uploaded by

65fhtrksh6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views11 pages

1. Your First Macro

This document provides an introduction to macros and the Visual Basic Editor (VBE) in Excel, including steps to record a macro, differences between relative and absolute recording, and how to run macros. It also includes instructions for fine-tuning settings on both Windows and Mac, as well as ways to run macros using various methods. The content is aimed at helping users become familiar with macro functionality and the VBE interface.

Uploaded by

65fhtrksh6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Your First Macro

Become familiar with macros and the Visual Basic Editor

Stephane Ruchet

© Ecole hôtelière de Lausanne


Overview: Macros & Visual Basic Editor (VBE)
• How to record a Macro
• Where your Macro is recorded
• Record our first Macros
• Difference between relative and absolute macro recording
• How to run Macros

2
Steps To Your First Macro Recording
• Do a test run before recording
• Record the macro
– Macro button on the left of the status bar
– Developer tab -> Record macro

• Name your macro, assign a shortcut and decide where to store it


• Run the macro
• Stop the macro 

3
Visual Basic Editor
• Hierachy :
– Close VBE -> Excel file stays open
– Close Excel File -> VBE closes
• One VBE for all open Excel files
• To open VBE
– ALT + F11 (Mac: ALT + Fn + F11)
– Developer Tab -> Visual Basic

4
Layout Personal Macro Insert Procedures,
Workbook Modules and Userforms
Edition options

Go back to Excel
ALT + F11
Run & stop your code

Project view

Macros are written


in Modules
Your code goes here !

Switch views between


Properties Window single or many procedures

Immediate Window :
great for code testing

5
Fine-Tune your setup (Windows)
• Excel -> Options -> Trust Center -> Trust Center Settings
• Macro Settings -> « Enable VBA macros »
• Protected View -> 3x Uncheck «Enable Protection View»

• VBE -> Tools -> Options


• Uncheck « Auto Syntax Check »
• Change the color for « Keyword text »
• Change the font size for « Normal text »

6
Windows Protection
• If you see the following message:

In File Explorer, browse to the location of your workbook, right-click the file, and
select Properties from the context menu. Check the “Unblock” box in the
Properties dialog box, then click OK.

7
Fine-Tune your setup (Mac)
• Enable all macros

8
Fine-Tune your setup (Mac)
• Open the Visual Basic Editor
• Excel -> Preferences

• Uncheck « Auto Syntax Check »


• Change the color for « Keyword text »
• Change the font size for « Normal text »

9
Disable Add-ins
• You do not need additional Add-ins activated for the scope
of the class. Disable them to clear the project explorer.

Under the Developer Tab, click on «Excel Add-ins» and


uncheck any available add-ins:

10
Different ways to run Macros
• Tab Developer -> Macros
• Use the assigned shortcut key (you can always assign a short key after saving)
• Add a shortcut in the Quick Access Toolbar
• Add a shortcut in the Ribbon
• Insert any shape/icon and assign the macro to it (right-click on the object)
• Insert a Form Control button
– Windows: Developer Tab -> Insert -> Form Controls
– Mac : Developer Tab -> Select relevant Form

Windows Mac

11

You might also like