The VB Editor is the application we use to write macros and create userforms. It can be opened by clicking the Visual Basic button on the Developer tab in Excel. The keyboard shortcut to open the VB Editor in any Windows version of Excel is Alt+F11. The shortcut in the Mac version is Opt+F11 or Fn+Opt+F11. I am not a VB programmer, just received some macros from a PC friend that I would like to run on my mac. I found the followng error The macro was probably written using VBA6 functions (WinXL2000+), but it's hard to tell without seeing the code. All Mac Office versions use VBA5.
Award-winning instructors
Get certified
Mobile (learn on-the-go)
Regularly updated content
Learn to automate your most repetitive tasks at the push of a button with Excel macros and VBA. In this online course, you will learn to create powerful macros using VBA (Visual Basic for Applications) to really make Excel work for you. With no prior programming experience required, you'll have your daily spreadsheets running like clockwork to save you hours of time and boost your productivity.
Highlights:
41 practical tutorials.
Understand the differences between macros and VBA.
Run your macro from the Macro dialog, a keyboard shortcut or worksheet button.
Understand the syntax and structure that make up a valid macro.
How VBA Objects and the Objects model relate to each other.
Using step vs run in entry level debugging.
How to create variables and assign strings, values or objects.
Implementing logic tests in VBA.
Set up looping with Do loops and Do While loops.
Create a VBA Message Boxes.
Set up an error trap in VBA to handle errors.
Create a User Defined Function (UDF).
Video tutorials are recorded in Microsoft Excel 2016 for PC. Learn more about how a GoSkills Excel certification can boost your career.
Want to be a more efficient Excel user? Start learning 200 of the best Excel shortcuts for PC and Mac.
Once enrolled, our friendly support team and tutors are here to help with any course related inquiries.
Certificate
Yes (learn more)
Accredited by
CPD
Video duration
3h 47m
Macros vs VBA - What's the Difference?
A brief discussion about the differences between macros and VBA, and how this course covers both.
Setting up the Macro Environment
Entry level steps to allow the user to record macros in Excel.
Creating Your First Macro
Recording a simple Macro in Excel.
File Types & Saving
A discussion on which files types support macros, and why it is critical to save your work before moving forward.
Running Macros: Using the Macro Dialog
How to run a macro from the Macro dialog.
Running Macros: Using Keyboard Shortcuts
How to run a macro from a keyboard shortcut.
Running Macros: Using Buttons
How to run your macro from a worksheet button.
Navigating the Visual Basic Editor
Meet the Visual Basic Editor (VBE) - your coding studio.
VBA Objects & the Object Model
A discussion of the different items you'll encounter as you learn to code, and how they relate to each other.
Excel's VBA Object Model
A visual view of a portion of Excel's object model.
Where Do I Put My Code?
Examining the different code containers and where you should place your code.
Understanding Code: Macro Syntax
Looking at the different keywords and structure that make up a valid macro.
Cleaning up Recorded Code
Editing the previously recorded code in order to remove unnecessary objects.
Step vs Run
How to step through a macro line by line in order to aid in debugging.
Using Breakpoints
How to set and use breakpoints during code development and debugging.
What are Variables?
A discussion of what variables are, and what they do for us when coding.
Creating Variables
Setting up variable dimensions and ensuring the code does so in the correct location.
Setting Variables
How to assign strings, values or objects to variables and use them in your code.
Explicit vs Implicit Variables
Why forgetting to set a simple flag can burn you in the long term.
Using the Locals Window
Working with the locals window to help you debug and explore the object model.
Using the Immediate Window
Exploring the benefits of the Immediate window for logging and querying, as well as writing when needed.
Using the Watch Window
How to use the Watch window to break code execution when variable conditions are met.
Using the Stop Keyword
How the Stop keyword can be used during code development similar to a breakpoint.
With Blocks
How 'With' blocks can tighten up your code and ensure your code targets the objects you expect.
Logic Tests: If Then Else
Implementing If/Then choices in VBA.
Logic Tests: Select Case
Understanding how the Select Case construct adds another logic test to your coding arsenal.
Loops: Basic Looping with Do Loops
Basic looping including counting iterations and exiting.
Loops: Looping under Conditions with Do While/Until Loops
More advanced looping by looping while or until a certain condition is met.
Loops: Looping X Iterations with For X to Y Loops
Running a loop a set number of times.
Loops: Looping Through Collections with For Each X in Y Loops
Using a For Each loop to cycle through each object in a collection such as each worksheet in a workbook's worksheets.
Calling Other Macros
Setting up a master macro allowing you to call other macros from a single source.
Creating VBA Message Boxes
How to provide feedback to your user via the VBA MsgBox object.
Collecting Feedback from a VBA MsgBox
Identifying which button the user clicked when presented with a MsgBox in order to use their response in our code.
Collecting Feedback from a VBA InputBox
Working with the VBA InputBox to prompt the user to enter information and capture it for later use.
Forcing User Input
Forcing users to enter data when requested.
Error Types
How to trigger various errors in VBA, and what they mean.
Trapping and Handling Errors
How to set up an error trap in VBA to handle errors.
Building Error Handlers
Setting up an error handling section for your macro.
User Defined Function (UDF) Syntax
The syntax signature for a UDF and how it differs from a standard subroutine.
Creating User Defined Functions (UDFs)
Creating a UDF to return the user name.
Calling a User Defined Function (UDF)
Calling a UDF from a worksheet and from VBA.
Make and Mail PDF files with VBA code on your Mac
Below you find examples for Excel 2011 and Excel 2016 for the Mac, if you are a Windows user check out the code in the Win Tips section of my site.
Excel 2016 for the Mac
Save as PDF in Mac Excel 2016 (29-7-2017)
Below you can find example VBA code to save as PDF in Mac Excel 2016. Microsoft fixed a few bugs but there are still a lot of bugs to fix, so I will update the code when needed. The code will create a folder in the Office folder to save the PDF files in, read the info on this page why I use a folder in that location. Check out this page if you want an easy way to open this folder in finder : Setup your Mac for Mac Office 2016
Save as PDF and attach to mail in Mac Excel 2016
Mac Outlook 2016 with Mac Excel 2016:
For Mac Outlook 2016 mail code visit this page for examples files and Add-in (1-Feb-2019)
Mac Mail with Mac Excel 2016:
For Apple Maill code visit this page for examples files (1-Feb-2019)
Excel 2011 for the Mac
Download the example workbook below with a few example macro's to create and mail PDF's in Excel 2011. Please test it and give feedback, good or bad. There are Mail examples in the workbook for Apple Mail and Outlook 2011.
Download example file : 29 Nov 2015
Note: Fixed a bug that it not attach the pdf to the mail when you use El Capitan as OS X.
Double-click the dmg file if it does not mount automatically. Drag the file to the folder you want on your Mac. Tip: Use one folder for all your example files (easy to backup your files this way)
Note: When you add new worksheets to the workbook the example code to make a PDF of the whole workbook do not include that sheet or sheets until you Close/Reopen the file.
There are a few problems(bugs) If you use VBA SaveAs or ExportAsFixedFormat or save a workbook manual as PDF. When you save the workbook as PDF it wil create a seperate PDF for each sheet in the workbook and it also add a sheet name to the file name of the PDF when you do it manual or with code.
My workeround is this : because creating a pdf of each sheet only happens the first time when you run the code I do this :
1: Create the PDF in a Temporary folder (code will create that for you) 2: Delete all files in this folder 3: Create the pdf again 4: Rename the PDF file (remove the sheet name) 5: Move the file to the folder you want
More Mail Examples
For more information and examples about mailing with VBA code from Mac Excel visit : Send Mail from Mac Excel