Macros are most commonly used to string several "cast" abilities together for use with one button. Each time that button is pressed, it will go through the abilities until it finds one it can use. This can be very useful in prioritizing abilities that have a cooldown associated with them, or with abilities that require some kind of condition in order to use.
A good example of this is a cleric macro that I use:
cast glory of the chosen
cast rage of the north
cast jolt
cast fated blow
cast soul drain
cast strike of the maelstrom
cast even justice
Each time this macro is pressed, it attempts to use each ability until it finds one it can use. So, it starts off with Glory of the Chosen. This is a self heal ability which can only be used after the cleric has suffered a critical hit. If the cleric has suffered a critical hit, then the ability is activated and the macro is complete. The rest of the abilities are ignored until it is pressed again. If the cleric has NOT suffered such a hit, then the macro continues on to the next ability, Rage of the North. This ability causes damage abilities to crit for the next 7 seconds, and it has a 1.5 minute cooldown. So, again, there is a check done. If the ability is off cooldown, it is cast and the macro is done. If it is on cooldown, we progress down the list. This continues for each item listed. If it CAN be cast when the button is pressed, it will cast and the macro is done. If not, it moves to the next item in the macro.
So, all that said, most macros of this type will end with an ability which has no cooldown and no special requirements to cast. In the above example, that ability is Even Justice. This ensures that each time the macro is pressed SOMETHING happens. If none of the other abilities are ready, then Even Justice is used. When the macro is spammed, repeatedly, you'll see a few of the cooldown abilities used at the start, then the Even Justice ability will be cast repeatedly until either one of the abilities with requirements is met (for instance, I get critically hit) or one of the cooldowns finishes.
At times, it can also be useful to include multiple abilities with no cooldowns, but with different uses. For example, if you have an instant cast after an ability with a cast timer, and both have no cooldown, you will use the one with a cast time any time you stand still because it is first in the list. However, if you are moving, the cast timer will prevent you from casting that spell, so the macro will move on to the instant cast and will use it instead.
There are lots of ways to tweak and customize macros to do all kinds of things. However, they are limited since only one ability can be used each time it is pressed, so if you throw your non-cooldown ability right at the start, the macro would never proceed to any of the other abilities.
There are also a number of non-ability related items that are used frequently in macros. These do not cause the macro to complete when they are used so can be used at the start or in the middle or wherever else is fitting. Things such as say, target, shout, etc. This allows you to create macros which will announce an ability as you cast it (such as a short period party buff like Flaring Power or Verse of Joy) or to target individuals or enemies at the push of a button, without having to search for them or type out the target command each time you need to re-target them.
Macros can ALSO be customized to behave differently depending on how you use them. You can set one macro to do different things depending on if you are holding shift, or control or have your mouse over an enemy or ally, etc.
As you can see, there is a lot that can be done with macros and they can serve many purposes. ZAM has a guide that seems to cover a lot of the basics here if you are interested.
» Edited on: 2012-03-27 09:03:37