One way is to Tools|Macro|Record a macro, give it a name and
then do the steps you want. Once done select Tools|Macro|Stop Recording
You can choose Tools|Macro|Macros and Edit the macro you created to see the
steps. In the Visual Basic Editor enter
Sub nameofyournewmacro and press enter
now you can enter the VBA code for your macro between Sub and End Sub...