Reputation: 3635
How to select open workbook when name of it is not constant. Lets say name for the file is "File 123 Name" and number part is changing daily. Tomorrow it could be "File 124 Name", day after "File 145 Name", etc.
Is there any way to select it by regexp or something else? I'm currently using Windows("File 456 Name").Activate
method. Essentially VBA code needs to match open workbook by some predefined pattern. Also it should return error if two open files are matching the same pattern.
Upvotes: 0
Views: 374
Reputation: 6654
Somthing like this ?
Sub Macro1()
For Each wb In Workbooks
If InStr(1, wb.Name, "File") > 0 And InStr(1, wb.Name, "Name") > 0 Then
Debug.Print wb.Name
End If
Next
End Sub
Upvotes: 1