Macros For Mac Excel
Test if it is a Mac or a Windows Machine
More information about testing the Excel version or Excel language you can find on this page : Mac Excel version and Mac Office language settings
You can useconditional compiler constants to test the Operating system or test if you run a 32 or 64 bit version of Office.
The macro below will test the Operating system, you can replace the msgbox line with your code or Macro call.
Activate the Developer Toolbar. To write macros, you will need access to the Developer toolbar in. Apr 17, 2018 Hi All, I have just finished developing a workbook choc full of macros for a client only to find out that they use a Mac and the Macros are not running! I have never worked on a Mac and want to know if there is anything that needs to be changed in the VBA to make them work or any settings that need to be adjusted?
Office 2011 for the Mac is always 32 bit and Office 2016 for the Mac can be 32 or 64 bit, all builds 15.26 and later are exclusively 64-bit. So every Mac Office 2016 install that is up to date is 64 bit.
Below you can find a test macro and three UDF functions that you can use to test theOperating system, test if you run a 32 or 64 bit version of Office and give you the Excel version number.
With the three functions above it is easy to test what you want in your VBA projects.
Note : Read this page about the version numbers : Mac Excel version and Mac Office language settings
New MAC_OFFICE_VERSION conditional compiler in Office 2016
In Mac Office 2016 they add a newconditional compiler constant named MAC_OFFICE_VERSION. In most cases you can test the Application.Version(>=15) if you want like I show you on this page:Mac Excel version and Mac Office language settings
But if you want to avoid compile errors with for example ribbon macro callbacks in Excel 2011(this not compile for example in 2011: control As IRibbonControl) or use VBA functions that are new in 2016 like AppleScriptTask and GrantAccessToMultipleFiles, you can add the ribbon macro callbacks or the new VBA functions in between the two code lines below in your code module.
#If MAC_OFFICE_VERSION >= 15 Then
Put your macro callbacks or code here
#End If
Macros are little programs that run within Excel and help automate common repetitive tasks. Macros are one of Excel’s most powerful, yet underutilized feature. Using macros, you can save hours and boost productivity manifold.
In this blog post, we will learn how to create an ultra-simple macro in Excel 2013 to introduce you to the concept. For a more detailed overview of advanced Excel functions, including creating complicated macros, try the comprehensive Excel training course for beginners and intermediate users.
What is a Macro?
A macro can be defined as the recording of a series of tasks. It’s the simplest form of automation – show a software program the steps you follow to get something done, and the software will follow along. When used right, macros can save you hours by automating simple, repetitive tasks.
Marcos in Excel are written in Excel VBA (Visual Basic for Applications). This is a version of Visual Basic (a prominent Microsoft programming language) developed specifically for use in Office-like applications. Creating simple macros – copy a formula from one cell to another, for instance – is fairly easy. Complicated macros require a bit more work. You’ll need to be quite intimate with Excel VBA to automate the more complex tasks in your workflow. You can learn more about these in this advanced Excel 2010 course.
For this tutorial, we will create a very simple macro to get you up to speed with Excel programming and automation.
Step 1: Activate the Developer Toolbar
To write macros, you will need access to the Developer toolbar in the top ribbon. This is hidden by default. To activate it, go to File -> Options -> Customize Ribbon and check the box next to ‘Developer’.
Press OK. You should now see the Developer toolbar in the ribbon.
Step 2: Enable Macros
Macros are disabled by default in Excel. This is to protect you from malicious macros running automatically in downloaded Excel files.
To use macros, you will have to first enable them from the Trust Center. To do this, go to File -> Options -> Trust Center. Click on the ‘Trust Center Settings’ button in this menu.
In this new window, go to ‘Macro Settings’ and select the ‘Enable all macros’ radio button.
Click OK. You can now start using macros in your Excel spreadsheets.
Step 3: Prepare the Spreadsheet
In this tutorial, we will create a very simple macro to change the color, size and boldness of text.
In your spreadsheet, type in some text in any of the cells. We will later record a macro to change the formatting of this text.
Now that our spreadsheet is ready, we can start creating the macro.
Step 4: Create a New Macro
In the ‘Developer’ tab, click on ‘Record Macro’
A pop-up window will ask you to give a name, storage location, shortcut and description for the macro.
Type in whatever you like over here. It helps to be descriptive with your macro titles. You might end up using dozens of macros in a large spreadsheet. Being able to quickly find individual macros by name will save you hours of frustration later. It’s also a good practice to add a description to remind you what the macro actually does.
Two important considerations here:
Shortcut Key: The shortcut key gives you quick access to the macro. Using a custom shortcut is highly recommended – you are using macros to save time, after all. A lot of default Excel functions are locked in to use the CTRL + Letter/Number shortcut format. To avoid conflicts with existing shortcuts, add not at least two keys to the shortcut – something like CTRL + SHIFT + A, or CTRL + A + 1
Store Macro in: In this drop down menu, you can decide where to save the macro. If you choose ‘ThisWorkbook’, the macro will be available for use in the existing workbook only. Choosing ‘NewWorkbook’ will, as you guessed, save the macro in a new workbook. The most powerful option here is to save the macro in ‘PersonalMacroWorkbook’. Macros stored in this workbook are available across all your workbooks. Think of it as a central repository for every macro that you create. The actual macro workbook file itself will be hidden the Windows AppData folder, but it will load up automatically when you start Excel, giving you complete access to all macros.
For the purpose of this tutorial, we will give our macro a shortcut of CTRL + SHIFT + A and store it within the same workbook.
Not sure how macros work? Try this comprehensive program to learn Excel 2010 from scratch.
Step 5: Record the Macro
Once you’ve entered all the require details, click OK. Your macro is now being recorded.
Select the cell where you entered your text. Switch to the ‘Home’ tab and change its color to red, font size to 18, and font weight to ‘bold’.
When you’re done, click on the ‘Stop Recording’ button in the Developer tab, or hit the small square block at the bottom of the spreadsheet next to ‘Ready’.
You have now successfully recorded an Excel macro!
Step 6: Test the Macro
Now that you’ve recorded your first macro, it’s time to see it live.
Add a few more blocks of text to your spreadsheet, one cell at a time. You might have to change the default formatting back to black font, 11 point font size and normal text.
Once you’ve added the text, simply select any cell and press the shortcut for your macro (CTRL + SHIFT + A). The formatting will immediately change to 18 pt. bold font in red color. You can apply this to each cell at a time, or select multiple cells together.
The formatting changes that would otherwise take you multiple clicks now take just one keystroke.
Excel Macro Tutorial Pdf
This is one of the most basic macros you can create. As you can imagine, complex macros can be created to perform very complicated tasks. You can learn more about creating such macros with Excel VBA programming in this Excel training course for advanced topics.
Was this tutorial helpful? We’d love to learn your thoughts and opinions! Share them with us in the comments below.