Sub test() For r = 1 To Workbooks.Count If Right(Workbooks(r).Name, 12) = "practice.xls" Then Workbooks(r).Activate Exit For End If Next r End Sub
_________________________________________________________________________________________________ "There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we know we don't know. But there are also unknown unknowns. There are things we don't know we don't know." ________________________________ From: Abhijat <ursabhi...@gmail.com> To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com> Cc: abhijat.si...@ubs.com Sent: Monday, 15 December, 2008 7:41:15 AM Subject: $$Excel-Macros$$ Window Selection based on name pattern 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 Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com -~----------~----~----~----~------~----~------~--~---