Buttons in VBA

This is short example showing how to create a button on the worksheet that moves to the next work sheet via a VBA macro.

Create a button by the menu above. This will prompt you to draw a box for the button to be placed on the sheet.

Here we can name our button and select a function to run when it is pressed. This produces the button below.

Right clicking on the button and selection "assign macro", then selecting "New" opens the VBA editor and creates and empty sub for us to use.

In the above example we have added a line of code that selects the worksheet called "Sheet2".

Pressing the button indeed moves the focus of the excel to sheet 2. Perfect!

Related Sections

Python - Learn the python from the basics up. This fast track example code course will get you creating powerful python programs in no time.

Must Read Articles

VBA and Microsoft Excel - Getting the most out of excel with VBA programming
VBA and Microsoft Word - Getting the most out of word with VBA programming
Application Object - Using the applications features in your code.
Installing VBA and First Program - What do you need to start using visual basic application VBA.