Opening a worksheet with a button?

J

joe

Hi Everybody:

I have 2 worksheets in a workbook. One acts like a main
menu and the other is like the data table. I created a
button in the main menu...but i'm stuck. My question is
how do I code the command button to open up that other
worksheet(data table)?

Joe
 
T

Tom Ogilvy

in design mode, double click on the button to get to the click event in the
code module of the sheet where the button is located. Or in any mode, right
click on the sheet tab and select view code, then( at the top of the
module) in the left dropdown select CommandButton1 and in the right select
Click

Private Sub CommandButton1_Click( )

End Sub

should be entered in the module. Put in code something like this untested
pseudo code.


Private Sub CommandButton1_Click()
Dim wkbk as workbook
On Error Resume Next
set wkbk = Workbooks("Data Table.xls")
On Error goto 0
if wkbk is nothing then
Workbooks.Open ThisWorkbook.Path & "\Data Table.xls"
ThisWorkbook.Activate
End if
End Sub

Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top