ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to open a Workbook and activate a specific sheet (https://www.excelbanter.com/excel-programming/307258-re-how-open-workbook-activate-specific-sheet.html)

Bob Phillips[_6_]

how to open a Workbook and activate a specific sheet
 
If it is a Forms commandbutton you could use the Caller property

Workbooks.Open Filename:="C:\myDir\myFile.xls"
Select Case Application.Caller
Case "Button 1": Worksheets("Sheet1").Activate
Case "Button 2": Worksheets("Sheet2").Activate
End Select

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Kanan" wrote in message
...
Hi,
I have a situation... where I have to open workbook1 which has 10 sheets
(sheet1...sheet10) from another workbook2 using different commandbuttons.
The question is how do I open workbook1 and activate different sheets

based
on the command button. Is there anyway to pass the sheet name as an

argument.
or Are there any other methods? My workbook1 does have an auto_open macro.

Kanan





All times are GMT +1. The time now is 09:43 PM.

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