Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default determine the active workbook containing a specific sheet

Dear experts,
I am trying to determine within my open workbooks the one that contains the
sheet "Instructions", workbook that I would like to activate.
My code (not working!) is the following:

i = 0
Do
i = i + 1
Loop Until IsError(Workbooks(i).Worksheets("Instructions")) = False
Workbooks(i).Activate
WBReport = Workbooks(i).Name

Could you please help me?
Many thanks!
Best regards,

--
Valeria
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default determine the active workbook containing a specific sheet

Function ActivateInstructions() As String
' Will activate the worksheet "Instructions"
' Returns the name of the workbook containing the sheet "Instructions"
' Note: If there happens to be more than one workbook with a sheet called
"Instructions" this will activate and return the one opened most recently.
' If no book contains a sheet called "Instructions" function returns an
empty string

Dim WB As Workbook
ActivateInsrtuctions = ""
For Each WB In Application.Workbooks
On Error GoTo NoInstructions
WB.Worksheets("Instructions").Activate
ActivateInstructions = WB.Name
NoInstructions:
On Error GoTo 0
Next WB
End Function

--
- K Dales


"Valeria" wrote:

Dear experts,
I am trying to determine within my open workbooks the one that contains the
sheet "Instructions", workbook that I would like to activate.
My code (not working!) is the following:

i = 0
Do
i = i + 1
Loop Until IsError(Workbooks(i).Worksheets("Instructions")) = False
Workbooks(i).Activate
WBReport = Workbooks(i).Name

Could you please help me?
Many thanks!
Best regards,

--
Valeria

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy value from active sheet to another workbook sak New Users to Excel 2 June 19th 09 10:52 AM
Consolidation of data from cell in active sheet of closed workbook Neil X Peel Excel Worksheet Functions 3 March 8th 07 02:35 PM
Open Specific Sheet in Workbook jhahes[_9_] Excel Programming 1 June 24th 05 09:26 PM
Auto Populate sheet name of active workbook in Combobox in Command Bhavtosh Excel Programming 2 January 24th 05 09:03 AM
Reliably get sheet 1 of the active workbook Michael D. Ober Excel Programming 6 October 27th 03 07:48 PM


All times are GMT +1. The time now is 03:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"