Question : Excel marco (close excel file and  auto rename)

Hi,

How can i command vba  , when i close  excel file and then execute  the following command.


Sub SaveFile()
    ThisWorkbook.SaveAs "D:\BACKUP\" & "SN" & Sheet1.Cells(2, 8).Text & ".xls"
End Sub


Regards
Stanley

Answer : Excel marco (close excel file and  auto rename)

Use 'BeforeClose' event of workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call SaveFile
End Sub
Random Solutions  
 
programming4us programming4us