I have a data validation set up in a set of files (A.xls, B.xls, C.xls) w/ the valid data lists (vdl.xls) in a separate workbook. I have macros in A, B, and C that run upon opening and closing that open and close vdl.xls. If a user opens both A & B, a window pops up with an error that vdl.xls is already open, and when they are both closed, a run-time error occurs. (Because closing A already closed vdl.xls, and upon closing B, the macro tries to close vdl.xls, but it is already closed.)
Is there code I can add to A, B & C that will only open/close vdl.xls if it isn't already opened/closed?
The code currently looks like this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("vdl.xls").Close SaveChanges:=False
End Sub
Private Sub Workbook_Open()
Application.ScreenUpdating = False
ChDir "T:\\HQ"
Workbooks.Open Filename:="T:\\HQ\vdl.xls"
ActiveWindow.Visible = False
Application.ScreenUpdating = True
End Sub
Bookmarks