View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Window Selection based on name pattern

Give subroutine a try...

Sub ActivateWS(SheetNameEnding As String)
Dim C As Worksheet
For Each C In Worksheets
If C.Name Like "*" & PartialSheetName Then
C.Activate
Exit For
End If
Next
End Sub

And call it from your own code (macro, function, event procedure, etc.) like
this...

ActivateWS "_practice.xls"

--
Rick (MVP - Excel)


"Abhijat" wrote in message
...
Hi Group,
I was wondering if there is a way in VBA to make that excel
spreadsheet as active window which has name ending with a fixed
string? For example: if a lot of excel spreadsheets are open at the
same time, all in the same session of course, my code should identify
the spreadsheet whose name is ending with something like
xxxxx_practice.xls and make it as active window.

Many thanks!

Best Regards,
Abhijat