Hello, can anyone help me with this one please. I have the following code to open up an excel workbook. For example the filepath and file name is - 'N:\Group\FTG Performance\FTG Performance 2003\may2003\ftg21may.xls'
The workbook name changes daily according to the date e.g. 'ftg02jan.xls', 'ftg12sep.xls' and so on. The workbooks are stored in sub folders according to the month of the year to which they relate e.g. 'ftg21feb.xls' in sub folder 'february2003' and so on. This is the VB code -
Dim C
C = "G:\Group\FTG Performance\FTG Performance 2003\may2003\"
Dim D As String
Dim M
M = "may"
Dim E
E = ".xls"
Dim G
G = "\ftg"
Dim FName As String
D = Format(Day(Now - 1), "00")
Dim WB As Workbook
Set WB = Workbooks.Open(Filename:=C & G & D & "" & M & E)
Windows(WB.Name).Activate
It works but every so often I have to edit the code so it opens the correct monthly sub folder e.g. '\may2003\' and the variable M="may" in these specific date formats. I wonder if anyone can help me to automate this please. I've tried to format the MONTH(NOW) but it keeps reverting to 'January'. Thanks in anticipation.
The workbook name changes daily according to the date e.g. 'ftg02jan.xls', 'ftg12sep.xls' and so on. The workbooks are stored in sub folders according to the month of the year to which they relate e.g. 'ftg21feb.xls' in sub folder 'february2003' and so on. This is the VB code -
Dim C
C = "G:\Group\FTG Performance\FTG Performance 2003\may2003\"
Dim D As String
Dim M
M = "may"
Dim E
E = ".xls"
Dim G
G = "\ftg"
Dim FName As String
D = Format(Day(Now - 1), "00")
Dim WB As Workbook
Set WB = Workbooks.Open(Filename:=C & G & D & "" & M & E)
Windows(WB.Name).Activate
It works but every so often I have to edit the code so it opens the correct monthly sub folder e.g. '\may2003\' and the variable M="may" in these specific date formats. I wonder if anyone can help me to automate this please. I've tried to format the MONTH(NOW) but it keeps reverting to 'January'. Thanks in anticipation.