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
Bookmarks