VBA EXCEL MENUTUP WORKBOOK SECARA OTOMATIS
Anda juga dapat mengunduh contoh file Kode macro Menutup Workbook Excel Secara otomatis
- Buka Microsoft Excel Anda
- Tekan Alt+F11 maka Anda akan dibawa ke jendela Visual Basic for Application (VBA)
- Buat satu buah Module
- Salin Kode Macro dibawah ini
Public RunWhen As Double
Public Const MENIT = 1 'workbook akan tertutup dalam waktu 1 menit
Public Sub Tutup()
ActiveWorkbook.Save
ThisWorkbook.Close savechanges:=False
End Sub
Public Const MENIT = 1 'workbook akan tertutup dalam waktu 1 menit
Public Sub Tutup()
ActiveWorkbook.Save
ThisWorkbook.Close savechanges:=False
End Sub
- Pada projek ThisWorkBook klik dua kali dan salin Kode Macro dibawah ini
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.OnTime RunWhen, "Tutup", , False
On Error GoTo 0
RunWhen = Now + TimeSerial(0, MENIT, 0)
Application.OnTime RunWhen, "Tutup", , True
- Simpan file dengan jenis enable macro dan ini biasanya extensinya .xlsm
Apabila Anda melakukan penjelasan diatas dengan benar maka Kode Macro Excel akan berjalan dengan semestinya tanpa ada pesan error atau the bug.
"Kami Selalu Berusaha Memberikan Yang Terbaik Dan Original Untuk Anda"
Jabat Erat@Hak Cipta 2015
2 comments for "KODE MACRO MENUTUP WORKBOOK EXCEL SECARA OTOMATIS"