Hello, one wonderful person helped me to figure out how to open folder from relative path
File which I want to open will be in "C:\GENERAL\2023\07 July\ or either another month
Is it any chance to amend this macro to open C:\GENERAL\2023\06 June\ if 07 July is empty or not exist?
Currently I have below
File which I want to open will be in "C:\GENERAL\2023\07 July\ or either another month
Is it any chance to amend this macro to open C:\GENERAL\2023\06 June\ if 07 July is empty or not exist?
Currently I have below
VBA Code:
Sub test()
Dim dt As String, dt2 As String
Dim filename As String, strMonth As String
Dim mth As Byte
Dim strMth As String, strPriorMth As String
Dim yr As String
yr = Year(Now())
strMth = MonthName(Month(Now()))
If Month(Now()) = 1 Then
mth = 1
strPriorMth = MonthName(12, True)
Else
mth = Month(Now() - 1)
strPriorMth = MonthName(Month(Now()) - 1, True)
End If
dt = Format(DateSerial(2023, mth, 1), "mm")
dt2 = Format(DateSerial(2023, mth, 1), "mmmm")
filename = "C:\GENERAL\" & yr & "\" & dt & " " & dt2 & "\" & "Handover*.xlsm"
Debug.Print filename
'Workbooks.Open filename
End Sub