0% found this document useful (0 votes)
12 views3 pages

Coding Simpan Dan Keluar

The document contains VBA code for the following functions: 1. A "Simpan" subroutine that saves the workbook. 2. A "Keluar" subroutine that prompts the user to confirm exiting the application, saves the workbook if confirmed, and closes it. 3. A "LOGIN" subroutine that checks user credentials against a login sheet, hides non-login sheets if invalid or shows them if valid. 4. Workbook event subs that hide non-login sheets before closing if not logged in, and initialize login fields on opening. 5. A "Cetak" subroutine that allows printing or clearing a report sheet after confirmation.

Uploaded by

Riyan Putra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Coding Simpan Dan Keluar

The document contains VBA code for the following functions: 1. A "Simpan" subroutine that saves the workbook. 2. A "Keluar" subroutine that prompts the user to confirm exiting the application, saves the workbook if confirmed, and closes it. 3. A "LOGIN" subroutine that checks user credentials against a login sheet, hides non-login sheets if invalid or shows them if valid. 4. Workbook event subs that hide non-login sheets before closing if not logged in, and initialize login fields on opening. 5. A "Cetak" subroutine that allows printing or clearing a report sheet after confirmation.

Uploaded by

Riyan Putra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sub Simpan()

ThisWorkbook.Save

End Sub

Sub Keluar()

Select Case MsgBox("Anda akan keluar dari aplikasi" _

& vbCrLf & "Apakah anda yakin?" _

, vbYesNo Or vbQuestion Or vbDefaultButton1, "Keluar")

Case vbNo

Exit Sub

Case vbYes

End Select

ThisWorkbook.Save

ThisWorkbook.Close

End Sub

>>>LOGIN<<<<<

Sub LOGIN()
Set L = Sheets("LOGIN")
Set U = Range("USER")
Set P = Range("PASWORD")
Set M = Range("PESAN")
If U.Value = "ADMIN" And P.Value = "1234" Then
For Each Worksheet In
Application.ActiveWorkbook.Worksheets
If Worksheet.Name <> "LOGIN" Then
Worksheet.Visible = True

End If
Next
With M
.Interior.Color = RGB(242, 242, 242)
.Value = ""
End With
L.Visible = xlverymidden
Else
With M
.Interior.Color = RGB(255, 39, 57)
.Value = "Maaf ! UserName dan Pasword salah "
End With
End If

End Sub

<<<<<<<TUTUP SETELAH LOGIN>>>>>>>>


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set L = Sheets("LOGIN")
Set U = Range("USER")
Set P = Range("PASWORD")
Set M = Range("PESAN")
L.Visible = True

For Each Worksheet In


Application.ActiveWorkbook.Worksheets
If Worksheet.Name <> "LOGIN" Then
Worksheet.Visible = xlVeryHidden

End If
Next
End Sub

Private Sub Workbook_Open()


Set L = Sheets("LOGIN")
Set U = Range("USER")
Set P = Range("PASWORD")
Set M = Range("PESAN")
U.Value = ""
P.Value = ""
With M
.Interior.Color = RGB(242, 242, 42)
.Value = ""
End With

End Sub
<<<<<<<<<<CETAK>>>>>>>>>>>

Private Sub CommandButton1_Click()

ActiveSheet.PrintPreview '<< Print Preview

Yakin = MsgBox(" Selesai cetak?", vbQuestion + vbYesNo, "Konfirmasi")

If Yakin = vbYes Then

Sheets("BRG_KELUAR").Range("l18:N32").ClearContents '<< MENGOSONGKAN TABEL NOTA

Sheets("BRG_KELUAR").Select '<< PILIH SHEET NOTA

End If

'ActiveSheet.PrintOut '<< Langsung Mencetak

End Sub

You might also like