Here is my code, but the AlreadyOpen is not being turned to True if the workbook is open.
' The code below is from the following sources: ' https://www.ozgrid.com/forum/forum/help-forums/excel-general/31023-open-workbook-if-closed-close-workbook-if-open ' https://www.encodedna.com/excel/how-to-open-a-file-dialog-box-in-excel-using-vba.htm AlreadyOpen = False For Each wb In Workbooks If wb.Name = "Job Expenditure Review.xlsm" Then AlreadyOpen = True Exit For End If With fd .Filters.Clear ' Clear all the filters (if applied before). ' Give the dialog box a title, word for doc or Excel for excel files. .Title = "Select a Text File to Open" ' Apply filter to show only a particular type of files. ' For example, *.doc? to show only word files or ' *.xlsx? to show only excel files. .Filters.Add "Excel Workbook Files", "*.xlsm?", 1 ' Do not allow users to select more than one file. ' Set the value as "True" to select multiple files. .AllowMultiSelect = False If .Show = True Then sFile = .SelectedItems(1) End If End With If sFile <> "" Then Workbooks.Open sFile ' Open the file. End If LastRow = Range("O" & Rows.Count).End(xlUp).Row Range("A2:P" & LastRow).ClearContents sFile = "" Next wb '
Any help would be appreciated.