Macro Archives - Excel Warrior https://excelwarrior.com/category/macro/ Excel Tips Thu, 08 Oct 2020 01:36:15 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 https://excelwarrior.com/wp-content/uploads/2020/10/cropped-excelwarrior-100-trans-32x32.png Macro Archives - Excel Warrior https://excelwarrior.com/category/macro/ 32 32 Excel Macros How to Use Relative References https://excelwarrior.com/excel-macros-relative-references/ Thu, 08 Oct 2020 01:36:11 +0000 https://excelwarrior.com/?p=76 “Relative references” sounds complicated but it’s really not. If you’re new to Macros then check out the beginner tutorial here. The best way to explain Relative references is to create a sample data set like the one below in Excel. Simply click and drag your mouse over the spreadsheet below and copy and paste it […]

The post Excel Macros How to Use Relative References appeared first on Excel Warrior.

]]>
“Relative references” sounds complicated but it’s really not. If you’re new to Macros then check out the beginner tutorial here.

The best way to explain Relative references is to create a sample data set like the one below in Excel. Simply click and drag your mouse over the spreadsheet below and copy and paste it into Excel.

125
2410
3615
4820
51025
61230
Total

It should look something like the table below:

Next select cell B7 and click on “Use Relative References.”

Then click on, “Record Macro.” And enter in this information:

Hit “OK.” You are now in recording mode.

Next, type in cell B7 the following formula and hit the Enter key.

=SUM(B1:B6)

Go to “Stop Recording Macro” and that’s all you need.

Now that you have recorded your macro, you can select cell D7 and run your macro by using the shortcut CTRL + SHIFT + M.

Do this and it will add up the rows. Or you can run it manually by hitting “Macros” and running the macro from the list.

So what is Releative reference? Well if you made this macro without relative reference, it would just keep summing up the B column again and again. Which would be no use, since we want to add up the D column and the F column.

Relative reference allows you to use your macro anywhere vs in a fixed cell location.

The macro we created is useful if you have 6 rows of numbers you want to add up.

The post Excel Macros How to Use Relative References appeared first on Excel Warrior.

]]>
How to Use Excel Macros (Creating Your First Macro) https://excelwarrior.com/excel-macro-how-to/ Tue, 06 Oct 2020 02:19:10 +0000 https://excelwarrior.com/?p=39 Excel macros make repetitive tasks easier. It’s similar to having a “speed dial” on your phone. With the press of a button you can call a friend vs having to manually punch in the number. Macros work the same way. With macros you can record actions and even have Excel do formulas. Like the speed […]

The post How to Use Excel Macros (Creating Your First Macro) appeared first on Excel Warrior.

]]>
Excel macros make repetitive tasks easier. It’s similar to having a “speed dial” on your phone. With the press of a button you can call a friend vs having to manually punch in the number.

Macros work the same way. With macros you can record actions and even have Excel do formulas.

Like the speed dial on your phone, you can assign shortcut keys to macros.

Recording Your First Macro

To record your first macro we will need to enable “developer mode” in Excel. By default this is hidden.

Choose File at the top left corner.

Select “Options” at the bottom left.

In the Excel Options dialog box, select Customize Ribbon.

In the list box on the right, place a check mark next to Developer.

Click OK to return to Excel.

Now you are ready to record your first Macro. You should now see “Developer” on your toolbar. Click on it and you will see some new options.

Macro Name Give your macro a descriptive name. For example, If you are adding a bunch of rows with this macro then you could call it something like, “AddNumMacro.”

Shortcut Key It’s optional to assign a shortcut key.

Store Macro This means that you will be storing your macro inside of your Excel file. So when you open the file at a future time, your macro will still be there. Also, if you send this Excel file to someone, they will also be able to use your macro.

Description This is useful if you have many macros and you need a quick reminder to refresh your memory. This is optional.

Try it out. Click on “Record Macro” and enter in this example:

Step 1) In the Macro Name put “My Company.”

Step 2) Assign a shortcut key by entering in a capital M. (shift + m).

Step 3) Click ok.

After clicking “OK” you will now be in “Recording” mode. And you will see the “Record Macro” button turn into the “Stop Recording” button. This means you are ready.

Type in your company or type in, “Acme Company” and hit enter.

Next, hit the “Stop Recording” button.

Great. Now you’ve recorded your first macro. You can now use your shortcut key CTRL + SHIFT + M and it should write the text out on to the cell. You may need to erase cell A1 and try it again to see it work.

We can view the code for the macro we created. Click on “View Code” in the Developer tab.

Your screen should look something like this. Double click on “Moduel1” and you should see the macro we created.

If your code does not look like this, it’s ok. You can delete any lines to make it look the same.

But as we can see, the main point is that this macro will write out text to a cell or when we run it manually. To run a macro manually simply, hit the “Macro” button and click on “Run.”

Congradulations you’ve created your first macro. Feel free to play around with this. Stay tuned for more tutorials from Excel Warrior.

The post How to Use Excel Macros (Creating Your First Macro) appeared first on Excel Warrior.

]]>