Sub UpdateHeaderDataVariable()
Application.ScreenUpdating = False
Dim WS As Worksheet
Dim InDate1 As String
Dim InDate2 As String
Dim InDate3 As String
Dim Date1 As Date
Dim Date2 As Date
Dim Date3 As Date
Dim FolderDate As String
FolderDate = ActiveWorkbook.Path
FolderDate = Mid(FolderDate, InStrRev(ActiveWorkbook.Path, "\") - 7, 7)
MsgBox FolderDate
' Check if Monthly_Report_Date_-_MM_YYYY.xls exists with MM-YYYY converted to FolderDate Variable
' If it exists, then go on with Sub, if it does not exist, show message box and then exit
If Dir("C:\Temp Downloads\VBA\" & FolderDate & "\[Monthly_Report_Date_-_" & FolderDate & ".xls") <> "" Then
MsgBox "File exists" ' For Testing Only, Real sub will not have message box
Else
MsgBox "File - Monthly_Report_Date_-_" & FolderDate & ".xls" & vbNewLine & "In Directory - C:\Temp Downloads\VBA\" & FolderDate & vbNewLine & "DOES NOT EXIST"
End If
InDate1 = "='C:\Temp Downloads\VBA\ " & FolderDate & " \[Monthly_Report_Date_-_" & FolderDate & ".xls]Sheet1'!$A$1"
Date1 = InDate1
'InDate1 = (cd ..) File (Monthly_Report_Date_-_??-???.xls, Sheet1, Cell A1)
'Date1 = CDate(InDate1)
'Set WS = Sheets("Sheet1")
' WS.PageSetup.CenterHeader = ""
' WS.PageSetup.CenterHeader = "Internal Report (Variable Here)"
' Format the Header here to be 16 point, Bold, Garmond
End Sub
|