0% found this document useful (0 votes)
21 views4 pages

Excel VBA Laporan Export Tutorial

The document contains VBA code for an Excel userform that allows users to search and export transaction and invoice data stored on different worksheets. The code includes procedures to populate dropdown lists on the form, search for data based on month and year selection, export search results to new Excel files, and reset the form fields. Procedures are provided to initially load transaction and invoice data onto the form and update the data based on user selections.

Uploaded by

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

Excel VBA Laporan Export Tutorial

The document contains VBA code for an Excel userform that allows users to search and export transaction and invoice data stored on different worksheets. The code includes procedures to populate dropdown lists on the form, search for data based on month and year selection, export search results to new Excel files, and reset the form fields. Procedures are provided to initially load transaction and invoice data onto the form and update the data based on user selections.

Uploaded by

Widha Filia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

=====================================================

CODING FORM LAPORAN | EXCEL VBA TUTORIAL


=====================================================
Option Explicit

Private Sub CBBULAN_Change()


[Link]("L2").Value = [Link]
End Sub

Private Sub CBBULAN1_Change()


[Link]("F2").Value = [Link]
End Sub

Private Sub CBTAHUN_Change()


[Link]("O2").Value = [Link]
End Sub
Private Sub CBTAHUN1_Change()
[Link]("H2").Value = [Link]
End Sub
Private Sub CMDEXPORT_Click()
On Error Resume Next
[Link]("U6").Value = [Link]("U6").Value + 1
[Link]("DATAEXPORT").Copy
[Link]
[Link]
[Link] = False
[Link] = False
[Link] Filename:= _
[Link] & "\" & "ExportNumber" & [Link]("U6").Value & ".xlsx",
FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
[Link]
[Link] = False
Call MsgBox("Data telah di Export", vbInformation, "Export Data")

End Sub

Private Sub CMDEXPORT1_Click()


On Error Resume Next
[Link]("M6").Value = [Link]("M6").Value + 1
[Link]("DATAEXPORT1").Copy
[Link]
[Link]
[Link] = False
[Link] = False
[Link] Filename:= _
[Link] & "\" & "ExportNumber" & [Link]("M6").Value & ".xlsx",
FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
[Link]
[Link] = False
Call MsgBox("Data telah di Export", vbInformation, "Export Data")

End Sub

Private Sub CMDGET_Click()


On Error GoTo Salah
Dim CARI_DATA As Object
Dim iRow As Long
Set CARI_DATA = Sheet5
[Link]("S6").Value = [Link]
[Link]("T6").Value = [Link]
CARI_DATA.Range("A5").[Link] Action:=xlFilterCopy,
CriteriaRange:= _
[Link]("S5:T6"), CopyToRange:=[Link]("A5:O5"), Unique:=False
Call HASILCARI
Exit Sub
Salah:
Call MsgBox("Maaf Data tidak ditemukan", vbInformation, "Cari Data")

End Sub
Private Sub HASILCARI()
'Perintah membuat variabel Jumlah Data
Dim DBTRANSAKSI As Long
Dim NomorBaris As Long
'Perintah mencari baris terakhir data
NomorBaris = [Link]("A" & [Link]).End(xlUp).Row
DBTRANSAKSI = [Link]([Link]("A6:A1000000"))
'Perintah memunculkan data dari Sheet ke Userform
If DBTRANSAKSI = 0 Then
[Link] = ""
Else
[Link] = "CARITRANSAKSI!A6:O" & NomorBaris
End If
End Sub

Private Sub CMDGET1_Click()


On Error GoTo Salah
Dim CARI_DATA As Object
Dim iRow As Long
Set CARI_DATA = Sheet7
[Link]("K6").Value = [Link]
[Link]("L6").Value = [Link]
CARI_DATA.Range("A5").[Link] Action:=xlFilterCopy,
CriteriaRange:= _
[Link]("K5:L6"), CopyToRange:=[Link]("A5:H5"), Unique:=False
Call HASILCARINOTA
Exit Sub
Salah:
Call MsgBox("Maaf Data tidak ditemukan", vbInformation, "Cari Data")
End Sub
Private Sub HASILCARINOTA()
'Perintah membuat variabel Jumlah Data
Dim DBNOTA As Long
Dim NomorBaris As Long
'Perintah mencari baris terakhir data
NomorBaris = [Link]("A" & [Link]).End(xlUp).Row
DBNOTA = [Link]([Link]("A6:A1000000"))
'Perintah memunculkan data dari Sheet ke Userform
If DBNOTA = 0 Then
[Link] = ""
Else
[Link] = "CARINOTA!A6:O" & NomorBaris
End If
End Sub
Private Sub CMDRESET_Click()
Call AmbilData
[Link] = ""
[Link] = ""
End Sub

Private Sub CMDRESET1_Click()


Call AmbilNota
[Link] = ""
[Link] = ""
End Sub

Private Sub UserForm_Initialize()


Call AmbilData
Call AmbilNota
With CBBULAN
.AddItem "Januari"
.AddItem "Februari"
.AddItem "Maret"
.AddItem "April"
.AddItem "Mei"
.AddItem "Juni"
.AddItem "Juli"
.AddItem "Agustus"
.AddItem "September"
.AddItem "Oktober"
.AddItem "November"
.AddItem "Desember"
End With
With CBBULAN1
.AddItem "Januari"
.AddItem "Februari"
.AddItem "Maret"
.AddItem "April"
.AddItem "Mei"
.AddItem "Juni"
.AddItem "Juli"
.AddItem "Agustus"
.AddItem "September"
.AddItem "Oktober"
.AddItem "November"
.AddItem "Desember"
End With
End Sub
Private Sub AmbilData()
'Perintah membuat variabel Jumlah Data
Dim DBTRANSAKSI As Long
Dim NomorBaris As Long
'Perintah mencari baris terakhir data
NomorBaris = [Link]("A" & [Link]).End(xlUp).Row
DBTRANSAKSI = [Link]([Link]("A6:A1000000"))
'Perintah memunculkan data dari Sheet ke Userform
If DBTRANSAKSI = 0 Then
[Link] = ""
Else
[Link] = "TRANSAKSI!A6:O" & NomorBaris
End If
End Sub
Private Sub AmbilNota()
'Perintah membuat variabel Jumlah Data
Dim DBTRANSAKSI As Long
Dim NomorBaris As Long
'Perintah mencari baris terakhir data
NomorBaris = [Link]("A" & [Link]).End(xlUp).Row
DBTRANSAKSI = [Link]([Link]("A6:A1000000"))
'Perintah memunculkan data dari Sheet ke Userform
If DBTRANSAKSI = 0 Then
[Link] = ""
Else
[Link] = "REKAPNOTA!A6:H" & NomorBaris
End If
End Sub

You might also like