0% found this document useful (0 votes)
12 views1 page

Coding Form Pencarian

This document is a tutorial for creating a search form in Excel using VBA. It includes code for searching data based on user input criteria and displaying results in a designated table. Additionally, it provides functionality for resetting the search fields and initializing the user form with predefined criteria options.

Uploaded by

duniamaya934
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)
12 views1 page

Coding Form Pencarian

This document is a tutorial for creating a search form in Excel using VBA. It includes code for searching data based on user input criteria and displaying results in a designated table. Additionally, it provides functionality for resetting the search fields and initializing the user form with predefined criteria options.

Uploaded by

duniamaya934
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
You are on page 1/ 1

---------------------------------------------

CODING FORM PENCARIAN - EXCEL & VBA TUTORIAL


---------------------------------------------

Option Explicit

Private Sub CMDCARI_Click()


On Error GoTo Salah
Dim CariData As Object
Set CariData = Sheet3
CariData.Range("O4").Value = Me.CMBKRITERIA.Value
CariData.Range("O5").Value = Me.TXTKATAKUNCI.Value
ActiveSheet.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:= _
Sheet3.Range("O4:O5"), Copytorange:=Sheet3.Range("A4:M4"), Unique:=False
Call HasilPencarian
Exit Sub
Salah:
Call MsgBox("Data tidak ditemukan", vbInformation, "Cari Data")

End Sub

Private Sub HasilPencarian()


Dim DBPENDUDUK As Long
Dim irow As Long
irow = Sheet3.Range("A" & Rows.Count).End(xlUp).Row
DBPENDUDUK = Application.WorksheetFunction.CountA(Sheet3.Range("A5:A1000000"))
If DBPENDUDUK = 0 Then
FORMUTAMA.TABELPENDUDUK.RowSource = ""
Else
FORMUTAMA.TABELPENDUDUK.RowSource = "PENCARIAN!A5:M" & irow
FORMUTAMA.CMDCETAK.Enabled = True
End If
End Sub

Private Sub CMDRESET_Click()


Me.CMBKRITERIA.Value = ""
Me.TXTKATAKUNCI.Value = ""
End Sub

Private Sub UserForm_Initialize()


With CMBKRITERIA
.AddItem "Nama Lengkap"
.AddItem "NIK"
.AddItem "No KK"
.AddItem "Pendapatan Perbulan"
.AddItem "Bantuan Pemerintah"
End With
End Sub

You might also like