Using Visual Basic for Applications (VBA) in Excel

STEP 1    Create a new Excel workbook.

STEP 2    Go to View/Toolbars/Control Toolbox.

excelvba1.gif (7961 bytes)

The Visual Basic Toolbox appears on Sheet1.

excelvba2.gif (6086 bytes)

STEP 3    Select the Command Button tool from the Toolbox and draw a button on  Sheet1.

excelvba3.gif (8329 bytes)

STEP 4     Move the cursor over the Command Button you just created until it turns into a four-way pointer (  cursor.gif (863 bytes)  )

STEP 5    Double-click the Command Button with the four-way pointer. The Visual Basic window appears ...

excelvba4.gif (17560 bytes)

STEP 6    Insert the Goto method as above:

Application.Goto Reference:=Worksheets("Sheet2").Range("A1")

STEP 7    Click the Run button

excelvba5.gif (8584 bytes)

 

STEP 7    Close the Visual Basic window and return to Sheet1. Click your new Button and you will be switched to Sheet2.

excelvba6.gif (8035 bytes)

Repeat the steps above to make a Button on Sheet2 that will take you back to Sheet1.

NOTE: If all you want to do is go between sheets, it may be easier to use the built-in Hyperlink technique, rather than VBA - Thanks Jody for the information.

Related VBA Sites:
http://www.scottm.dircon.co.uk/vbatips/
http://www.vbatutor.com/
http://lacher.com/


Return to Home Page