HOW TO EXIT ACTIVE WORKBOOK

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

1) I want to know how to exit active workbook using macro. Let say I open few files together (around 4). When user click macro button one of this the files, MS.Excel will - save the data & exit for the active file only

2) How to set a counter that show number of times that files open

Thanks
 
Hi
1. Try something like the following:
sub foo()
dim wbk as workbook
set wbk = workbooks("yourfile.xls")
wbk.save
wbk.close
end sub

2. Use the workbook_open event for this. Something like
sub workbook_open()
dim wks as worksheet
set wks=me.worksheets("sheet1")
with wks.range("A1")
.value=.value+1
end with
end sub
 
Back
Top