Hi,
I'm no expert but i can start you off.
If you count the number of open workbooks first then build an If function around the numer returned you can say: if there are more than 1 workbooks open then, do something, otherwise close and save changes.
Thefollowing works but i dont fully understand why itis telling me i have two open when i only have 1 open so i set the value to 2 to show that the logic works.
Might be my personal macro wk who knows
Code:Sub WORKBOOKS() nowbs = Application.WORKBOOKS.Count If nowbs < 2 Then Application.WORKBOOKS.Close Else End If MsgBox nowbs End Sub



Reply With Quote

Bookmarks