ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a worksheet with a button? (https://www.excelbanter.com/excel-programming/271807-opening-worksheet-button.html)

joe

Opening a worksheet with a button?
 
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

Tom Ogilvy

Opening a worksheet with a button?
 
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

"joe" wrote in message
...
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





All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com