This is how you make any bar swap with stance using a macro. Posting cause i recently was suprised how many didn't know about it even among high rated players.
Its basically pretty simple, there is a [stance:X] modifier that works just like [modifier:alt] . It sets the condition that you have to be in stance x to use the cast/action.
Important: to let the icon switch to the skill that will be used don't select an icon when you create a macro. The per default selected red question mark should stay selected for this to work.
A simple stance dependant macro looks like this:
------------------------------------------
#showtooltip
/cast [stance:1] bear_attack_skill
/cast [stance:3] cat_attack_skill
------------------------------------------
With this the button will change to the skill depending wether you are in bear or cat stance
You can check the numbers for your stances here: Stance - WoWWiki - Your guide to the World of Warcraft
I myself play a rogue and the currently most important macro for me is
-------------------------------------------
#showtooltip
/cast [stance:0] Backstab
/cast [stance:1/3] Ambush
-------------------------------------------
It will cast Backstab out of stealth and Ambush in stealth (stance 1) or shadowdance (stance 3)
This also circumvents the bug where sometimes the bar isnt switching to the stealth bar when you activate shadowdance
For a warrior you can add the [combat] modifier and create an instant gapcloser macro
-------------------------------------------
/cast [nostance:1,nocombat] Battle Stance
/cast [stance:1,nocombat] Charge
/cast [nostance:3,combat] Berserker Stance
/cast [stance:3,combat] Intercept
-------------------------------------------
This will automatically switch to the right stance and use charge or intercept depending on if you are in combat or not.
With this you can now make any button change with your stance. Have fun.