Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

' -----------------------------------------------------------

'| YouTube Channel : Http://youtube.com/lundankexcel |


'| My Blog : informasi-beritaandre.blogspot.com |
' -----------------------------------------------------------
' _ _ ____ __
' /_\ _ __ __| | _\ _____ / _\\ //
' //_\\| '_ \ / _` | |(_)\ _ \ \ \ \ /
'/ _ \ | | | (_| | | ---| ___/_ _\ \| |
'\_/ \_/_| |_|\__,_|_| \_ \_____| \__/|_|
'
' Auth : Andre Syafirman
' Date : 02 Januari 2020
' About : Search Data

Sub TAMPILDATABARANG()
On Error GoTo SALAH
With TABELBARANG
.RowSource = "TBLBARANG"
.ColumnCount = 5
.ColumnWidths = "80, 120, 70, 70, 50"
.ColumnHeads = True
End With
SALAH:
End Sub

Private Sub CMBPILIH_Change()


On Error GoTo SALAH
Dim CARIBARANG As Object
'Perintah menentukan tempat pencarian data
Set CARIBARANG = Sheet1
'Perintah Menentukan tempat Kriteria Pencarian
CARIBARANG.Range("G1").Value = Me.CMBPILIH.Value
SALAH:
End Sub

Private Sub TextBox1_Change()


On Error GoTo SALAH
Dim CariDataBarang As Object
Set CariDataBarang = Sheet1
CariDataBarang.Range("G1").Value = CMBPILIH.Value
CariDataBarang.Range("G2").Value = Me.TextBox1.Value
CariDataBarang.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:= _
Sheet1.Range("G1:G2"), Copytorange:=Sheet1.Range("I3:M3"), Unique:=False
Me.TABELBARANG.RowSource = Sheet1.Range("CARIDATABARANG").Address(EXTERNAL:=True)
Exit Sub
Call MsgBox("Data tidak ditemukan", vbInformation, "Cari Data")
SALAH:
End Sub

Private Sub UserForm_Initialize()


FORMBARANG.BackColor = &H400000
Label1.BackColor = &H400000
Label1.ForeColor = &HFFFFFF

With CMBPILIH
.AddItem "Kode Barang"
.AddItem "Nama Barang"
End With
Call TAMPILDATABARANG
End Sub

You might also like