I have 2 workbooks A & B.
With B open, I add data to a worksheet.
Then when I open A, I need it to close B and save the changes I've made to B.
What code can I add to A & B do this, and where should it be located.
Printable View
I have 2 workbooks A & B.
With B open, I add data to a worksheet.
Then when I open A, I need it to close B and save the changes I've made to B.
What code can I add to A & B do this, and where should it be located.
Paste the code in ThisWorkbook module
Code:Private Sub Workbook_Open()
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("B.xlsx")
On Error GoTo 0
If Not wb Is Nothing Then
wb.Close Not wb.Saved
End If
End Sub