Using wildcard for checking whether files are open
I have macros that are used by several files.
One of the macros creates the toolbar, then I have a Closebook macro that checks whether how many files are still open. When the last file is being closed, the macro deletes the toolbar. I am starting to have more files that need to be checked and I am wondering if there is a way to put a wildcard in the checking of the name. For example, if workbook name is Price List*.xls then .... Here's the code that I currently have - Count = 0 ListName = "Price List - " For Each wkbk In Application.Workbooks If wkbk.Name = ListName & "Central.xls" Then Count = Count + 1 End If If wkbk.Name = ListName & "Eastern.xls" Then Count = Count + 1 End If If wkbk.Name = ListName & "Western.xls" Then Count = Count + 1 End If Next If Count <= 1 Then On Error Resume Next Application.CommandBars("Price List").Delete End If Thanks for your help. Monique |
Using wildcard for checking whether files are open
Try
If wkbk.Name Like "something*" Then -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl wrote in message ... I have macros that are used by several files. One of the macros creates the toolbar, then I have a Closebook macro that checks whether how many files are still open. When the last file is being closed, the macro deletes the toolbar. I am starting to have more files that need to be checked and I am wondering if there is a way to put a wildcard in the checking of the name. For example, if workbook name is Price List*.xls then .... Here's the code that I currently have - Count = 0 ListName = "Price List - " For Each wkbk In Application.Workbooks If wkbk.Name = ListName & "Central.xls" Then Count = Count + 1 End If If wkbk.Name = ListName & "Eastern.xls" Then Count = Count + 1 End If If wkbk.Name = ListName & "Western.xls" Then Count = Count + 1 End If Next If Count <= 1 Then On Error Resume Next Application.CommandBars("Price List").Delete End If Thanks for your help. Monique |
All times are GMT +1. The time now is 02:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com