- In your workbook hit Alt + F11 to open the VBA editor.
- Find your workbook's name in the VBAProject window on the left
- Right click --> Insert --> Module
- You can rename the module if you like
- Double click on the newly created module
- Paste the following code into it
Edit the items in the code marked "Change" or "Change to suit"!
Now to add a button to your sheet to execute the code!
In Office 2010 or 2013 follow these steps to add the Developer Tab if you don't have it- Click on File
- Click on Options
- Click on Customize Ribbon
- Check "Developer" in the list on the right
- Click OK
Back in your sheet...- Click on the Developer Tab
- Click on Insert
- From the drop down select the top leftmost icon ... Button Form control
- It will create a cross hairs for you to draw the button where you want it
- After drawing the button a dialog will pop up for you to select the macro you want executed when the button is clicked
- Select your new macro's module name
Bookmarks