Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking to see if Workbook is open
I am trying to write VBA code that will look first to see if another workbook
is open, if open then go to sheet 1, if not open, then open it and go to sheet 1. You see I might need to go to this sheet several different times during the day and I don't want to keep opening and closing the sheet. Steve |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking to see if Workbook is open
Dim oWB As Workbook
On Error Resume Next Set oWB = Workbooks("myBook") On Error GoTo 0 If oWB Is Nothing Then Set oWB = Workbooks.Open("C:\myDir\myBook.xls") End If oWB.Worksheets("Sheet1").Activate -- HTH RP (remove nothere from the email address if mailing direct) "caldog" wrote in message ... I am trying to write VBA code that will look first to see if another workbook is open, if open then go to sheet 1, if not open, then open it and go to sheet 1. You see I might need to go to this sheet several different times during the day and I don't want to keep opening and closing the sheet. Steve |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking to see if Workbook is open
Thanks Bob, the code worked just the way I want.
Steve "Bob Phillips" wrote: Dim oWB As Workbook On Error Resume Next Set oWB = Workbooks("myBook") On Error GoTo 0 If oWB Is Nothing Then Set oWB = Workbooks.Open("C:\myDir\myBook.xls") End If oWB.Worksheets("Sheet1").Activate -- HTH RP (remove nothere from the email address if mailing direct) "caldog" wrote in message ... I am trying to write VBA code that will look first to see if another workbook is open, if open then go to sheet 1, if not open, then open it and go to sheet 1. You see I might need to go to this sheet several different times during the day and I don't want to keep opening and closing the sheet. Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
Opening Excel, Book1 opens, remains open with other workbook open | Excel Discussion (Misc queries) | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation | Excel Programming |