Salam...,
Microsoft Excell 2010 ternyata memberikan kemudahan untuk kita dalam melakukan pengolahan data. Kaliini kita akan membuat Kartu stok yang secara otomatis berjalan sehingga informasi tentang transaksi Persediaan dengan mudah dapat ditampilkan.
Ok langsung saja kita buat..!
Pertama sekali buka Ms.Excell nya.....
1. Buatlah Tabel Data Transaksi, seperti berikut..
2. Klik Tab Developer lalu klik Icon Visual Basic, Buatlah Form dengan Design Seperti berikut...
Setelah itu masukkan Coding berikut :
Private Sub CommandButton1_Click()
On Error Resume Next
Worksheets("Sheet1").Activate
Dim rngNames As Range
Dim arrNames
Dim arrResults
Dim lngRow As Long
ProductCode = Me.txtcode.Value
If ProductCode = Empty Then
MsgBox "Product Code Belum diisi..."
Me.TextBox1.SetFocus
Exit Sub
End If
With Worksheets("Sheet1")
Set rngNames = .Range("A3", .Range("A" & Rows.Count).End(xlUp))
End With
With rngNames
arrNames = Evaluate(.Address & "&CHAR(45)&ROW(" & .Address & ")")
End With
arrNames = Application.Transpose(arrNames)
arrResults = Filter(arrNames, ProductCode)
ListBox1.Clear
UserForm_Activate
If UBound(arrResults) = -1 Then
ListBox1.AddItem "Data Tidak Ada"
Else
For i = LBound(arrResults) To UBound(arrResults)
lngRow = Mid(arrResults(i), InStrRev(arrResults(i), "-") + 1)
With ListBox1
.AddItem
.List(.ListCount - 1, 0) = Worksheets("Sheet1").Range("D" & lngRow)
.List(.ListCount - 1, 1) = Worksheets("Sheet1").Range("E" & lngRow)
.List(.ListCount - 1, 2) = Worksheets("Sheet1").Range("F" & lngRow)
.List(.ListCount - 1, 3) = Worksheets("Sheet1").Range("G" & lngRow)
.List(.ListCount - 1, 4) = Worksheets("Sheet1").Range("H" & lngRow)
End With
Next i
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
Me.ListBox1
Call UserForm_Activate
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub UserForm_Activate()
With ListBox1
.AddItem
.List(.ListCount - 1, 0) = "Product Code"
.List(.ListCount - 1, 1) = "Tanggal"
.List(.ListCount - 1, 2) = "Keterangan"
.List(.ListCount - 1, 3) = "Qty In"
.List(.ListCount - 1, 4) = "Qty Out"
.ColumnWidths = 80 & " , " & 120 & "," & 100 & "," & 70 & "," & 70
End With
End Sub
3. Jalankan Programnya,
Ok, sekian dulu tutorial VBA Ms.excell 2010 cara pembuatan Kartu Stok Otomatis,
untuk selanjutnya silahkan Anda kembangkan.
Pelajari Juga Tutorial VBA MS.Excell 2010 berikut ini ;
Salam...,
No comments:
Post a Comment