I have some code which im running which i do not fully understand.
My aim is to open a folder, thats always last month, so this month it will open July
On the 1st August, this was correct, but today it is looking for an August folder, therefore debugging as it does not exist
My suspicion is it is due to the line If Day(Date) = 1, can i remove that, is this necessary?
Any time of the month, i always want to search for the previous month
FileYear = Year(Date)
MonthOffset = 0
If Day(Date) = 1 Then MonthOffset = 1
FileMonth = Month(Date) - MonthOffset
FileDate = Format(Date - 1, "yyyymm")
FilePath = "R:\SPM\Monthly_Inputs\" & FileYear & "\" & FileDate & "\Reporting\PCM_Cross_Region_Lost_Raw.xlsx"