Hi, I get sent a file each day called 'Daily_Sales_ddmmyy'.xlsb, so todays was called Daily_Sales_140218.xlsb
The code below loops though ther open workbooks until it finds the Daily_Sales file, I know to have that file open before I trigger the Procedure which pulls this file into my Master Workbook where the VBA is stored. As the Workbook Name changes each day, I've gone for the approach below as I can't hard code the Daily File name into the workbook.
What could I add as a fail-safe incase the Daily File isn't open,
I've tried
but this runs to the Exit Sub even if the Daily_Sales file is open.
Thanks for any help
The code below loops though ther open workbooks until it finds the Daily_Sales file, I know to have that file open before I trigger the Procedure which pulls this file into my Master Workbook where the VBA is stored. As the Workbook Name changes each day, I've gone for the approach below as I can't hard code the Daily File name into the workbook.
Code:
Dim DHFile as Workbook 'Daily File
For Each wb in Application.Workbooks
[indent]If wb.Name Like "Daily Sales*" Then[/indent]
[indent]Set DHFile = wb[/indent]
[indent]End If[/indent]
Next wb
I've tried
Code:
If wb Is Nothing then Msgbox" The Daily Sales file must be opened before continuing":Exit Sub
Thanks for any help