ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open worksheet (https://www.excelbanter.com/excel-programming/344933-open-worksheet.html)

Benjamin

open worksheet
 
Is there a way to open a specific worksheet based on the contents of a cell
in the source worksheet..

Workbooks.Open Filename:="C:\filename.xls#(worksheet name in A1)!A1"

TIA

Ben

Jim Thomlinson[_4_]

open worksheet
 
Here is some code for you to try. You jsut need to get the workbook and sheet
names added in

Sub OpenToSheet()
Dim wbk As Workbook

Workbooks.Open ("C:\ThisBook.xls")
Set wbk = ActiveWorkbook
wbk.Sheets("Sheet1").Select
MsgBox "Here we are"
ThisWorkbook.Activate
MsgBox "And now we are back..."
End Sub
--
HTH...

Jim Thomlinson


"Benjamin" wrote:

Is there a way to open a specific worksheet based on the contents of a cell
in the source worksheet..

Workbooks.Open Filename:="C:\filename.xls#(worksheet name in A1)!A1"

TIA

Ben


Benjamin

open worksheet
 
Thanks. But say I don't want to type in the name of the worksheet, but refer
to it's name which is stored in cell A1.

"Jim Thomlinson" wrote:

Here is some code for you to try. You jsut need to get the workbook and sheet
names added in

Sub OpenToSheet()
Dim wbk As Workbook

Workbooks.Open ("C:\ThisBook.xls")
Set wbk = ActiveWorkbook
wbk.Sheets("Sheet1").Select
MsgBox "Here we are"
ThisWorkbook.Activate
MsgBox "And now we are back..."
End Sub
--
HTH...

Jim Thomlinson


"Benjamin" wrote:

Is there a way to open a specific worksheet based on the contents of a cell
in the source worksheet..

Workbooks.Open Filename:="C:\filename.xls#(worksheet name in A1)!A1"

TIA

Ben


Dave Peterson

open worksheet
 
option explicit
sub testme01()

dim wkbk as workbook
dim wksName as string

wksname = activesheet.range("a1").value

set wkbk = workbooks.open(filename:=c:\filename.xls")

on error resume next
application.goto wkbk.worksheets(wksname).range("a1"), scroll:=true
if err.number < 0 then
beep
err.clear
end if

end sub



Benjamin wrote:

Is there a way to open a specific worksheet based on the contents of a cell
in the source worksheet..

Workbooks.Open Filename:="C:\filename.xls#(worksheet name in A1)!A1"

TIA

Ben


--

Dave Peterson


All times are GMT +1. The time now is 01:48 AM.

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