You can use the Beforeclose event.
Chip Pearson has general information on Events:
http://www:cpearson.com/excel/vbe.htm
in the event you would have something like
Dim bClose as Boolean
Dim bk as workbooks
On Error Resume Next
set bk = workbooks("Master.xls")
On Error goto 0
if bk is nothing then
bClose = True
set bk = Workbooks.Open("C:\Myfolder\Master.xls")
end if
bk.worksheets(1).Range("C1:C5").Value =
worksheets(1).Range("A1:A5").Value
bk.Save
if bClose then
bk.Close Savechanges:=False
End if
Application.EnableEvents = False
thisworkbook.Save
Application.EnableEvents = True
--
Regards,
Tom Ogilvy
"ole_" wrote in message
...
Hi ng,
I have a problem, i have 15 different xls files and one master, i want to
create a macro that when you push
it, it exports range A1:A5 to the master xls (example file1.xls exports
range A1:A5 to master.xls range A1:A5, file2.xls
exports range A1:A5 to master.xls range B1:B5 and so on), also the macro
should save the file at the same time.
It could be when you leave the file, but the user should not have a
possibility to say no.
I hope you understand my problem and can help me,
regards,
Ole