Closing After Save Event

Magdoulin

Board Regular
Joined
Jan 11, 2013
Messages
73
Hi Guys, would you please help.

I'd this workbook event before and it was working just fine

Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
If Success Then
ThisWorkbook.Close
End If
End Sub

However, I needed to proceed with some changes for the event, yet, it doesn't work for closing part anymore:

Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim i As Long
i = ActiveCell.Column
Cells(Range("A65536").End(xlUp).Row + 1, 1).Select
ActiveCell.Resize(2).EntireRow.Copy Sheets("Report").Range("A" & Rows.Count).End(xlUp).Offset(1)
ActiveCell.Offset(0, 11).Value = Format(Now(), "dd/mm/yyyy")
ActiveCell.Offset(0, 12).Value = Format(Now(), "hh:nn:ss")
If Success Then
ThisWorkbook.Close
End If
End Sub


How I could sort this out?

Another point, I'd like to add part for this event to run the first part only if the active sheet name is one of the available names in Worksheets("DB").Range("A1:A100"), otherwise, to just save and close, is it doable?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top