i am trying to write a vba macro in excel that says if a filename (which is a string) is open, then to do something with it.
I am getting an error, highlighting "If Sheets(Fname).Open = True Then" saying subscript out of range.
Everything works up until that line, I add msgboxes to help me see i'm keeping my filename and my code works.
Dim Wb As Workbook ' current workbook
Dim Report As Workbook ' referenced workbook
Dim Ffn As String ' full file name of Report
Dim Fname As String ' retrieved file name
Ffn = "H:\Futures\Macros\F&O Report\F&O Report Instructions Macro 1-22-2014.xlsm"
Set Report = GetWorkbook(Ffn)
If Report Is Nothing Then
MsgBox "Couldn't find the Report", vbCritical, _
Fname = Report.Worksheets(1).Range("A11").Text & ".xlsx"
If Sheets(Fname) = True Then
MsgBox "Good, file opened."
MsgBox "Today's report is currently not opened."
'If Len(Fn) Then