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

Pti

Uploaded by

chyaangela1234
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 views2 pages

Pti

Uploaded by

chyaangela1234
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/ 2

User form

Private Sub BTAmbil_Click() Set hc = isidata = Array(baris - 1,


Dim dbarea As Range dbarea.Find(TBIDBarang, , TBIDBarang.Value,
Dim hc As Range xlValues, xlWhole) TBNamaBarang.Value,
If TBIDBarang.Text = " " If hc Is Nothing Then CBJenisBarang.Value,
Then MsgBox "id barang yang TBHargaBarang.Value)
MsgBox "silahkan isi ID diinput tidak ada", Sheet1.Range("a" &
barang terlebih dahulu", vbInformation, hapus baris).Resize(1, 5).Value =
vbCritical, ambil Else isidata
Exit Sub hc.EntireRow.Delete MsgBox "data berhasil
End If MsgBox "data berhasil disimpan", vbInformation,
Set dbarea = dihapus", vbInformation, simpan
Sheet1.Range("b2:b" & hapus Call bersih
getbaris) End If TBIDBarang.Text = buatid
Set hc = TBIDBarang.Text = buatid End Sub
dbarea.Find(TBIDBarang, , Call urut
xlValues, xlWhole) End Sub Private Sub
If hc Is Nothing Then Private Sub urut() UserForm_Initialize()
MsgBox "ID barang yang di Dim i As Long CBJenisBarang.RowSource =
cari tidak ada", For i = 2 To getbaris Sheet1.Range("i1:i2").Addre
vbInformation, hapus Sheet1.Range("a" & i).Value ss
Call bersih =i-1 Call bersih
TBIDBarang.Text = buatid Next i TBIDBarang.Text = buatid
Else End Sub End Sub
TBIDBarang.Text = hc.Value
TBNamaBarang.Text = Private Sub BTKeluar_Click() Private Sub bersih()
hc.Offset(0, 1).Value MsgBox "I'm Lucky to have TBIDBarang.Text =
CBJenisBarang.Text = u <3", vbInformation, chyky vbNullString
hc.Offset(0, 2).Value Unload Me TBNamaBarang.Text =
TBHargaBarang.Text = End Sub vbNullString
hc.Offset(0, 3).Value CBJenisBarang.Text =
End If vbNullString
End Sub TBHargaBarang.Text =
Private Sub BTBatal_Click() Private Sub vbNullString
Call bersih BTsimpan_Click() End Sub
TBIDBarang.Text = buatid Dim baris As Long
End Sub Dim dbarea As Range, hc As Private Function buatid() As
Range String
Private Sub BTHapus_Click() Dim isidata As Variant Dim baris As Long
Dim dbarea As Range Set dbarea = Dim idlama As String
Dim hc As Range Sheet1.Range("b2:b" & baris = getbaris
If TBIDBarang.Text = "" Then getbaris) If Not baris = 1 Then
MsgBox " silahkan isi id Set hc = idlama = Sheet1.Range("B"
barang terlebih dahulu", dbarea.Find(TBIDBarang, , & baris)
vbInformation, hapus xlValues, xlWhole) baris = CLng(Right(idlama,
Exit Sub If hc Is Nothing Then 5)) + 1
End If baris = getbaris + 1 End If
Set dbarea = Else buatid = "ID" &
Sheet1.Range("b2:b" & baris = hc.Row Format(baris, "00000")
getbaris) End If End Function
Module 1

Sub BUKA_Click()

UserForm1.Show

End Sub

Module 2

Const chyky As String = "masukin data"

Function getbaris() As Long

getbaris = Sheet1.Range("a" & Sheet1.Rows.Count).End(xlUp).Row

End Function

You might also like