Hi
At the top left of the spreadsheet, immediately to the left of File on the toolbar, right click o the spreadsheet icon, select view code. There are 2 dropdowns and the left one should default to general. Select the drop down, and take workbook. On the right dropdown, select before_close. Put in your macro and it will run before the spreadsheet is closed.
HTH
Tony