Documente Academic
Documente Profesional
Documente Cultură
TxtUser.SetFocus
End Sub
Set Sh = Sheets("Pengaturan")
MsgBox "Please Type User Name", vbExclamation + vbOKOnly, "Blank User Name"
TxtUser.SetFocus
Exit Sub
TxtPswd.SetFocus
Exit Sub
TxtUser.SetFocus
Exit Sub
MsgBox "Wrong Password, please retype again", vbCritical + vbOKOnly, "Error Password"
TxtPswd.SetFocus
Exit Sub
End If
MsgBox "Congratulation " & Sh.Range("H9").Value & ", Login Success...!", vbInformation +
vbOKOnly, "Log in"
Unload Me
Sheet1.Activate
End Sub
ActiveWorkbook.Close (vbOKOnly)
End Sub
If CloseMode = 0 Then
Cancel = True
MsgBox "Tombol X tidak diaktifkan, silahkan klik tombol Cancel untuk menutup aplikasi.",
vbCritical
End If
End Sub
KODE FORM NB
IdVal = fn_LastRow(Sheets("dtbaseNB"))
frmNB.txtId.Value = Sheet5.Range("A1").Value
frmNB.txtId.ForeColor = rgbBlack
frmNB.Caption = Sheet2.Range("D19").Value
txt_1.Locked = False
txt_1.Locked = True
txt_2.SetFocus
End If
lbl_4.Visible = True
txt_4.Visible = True
lbl_4.Visible = False
txt_4.Visible = False
End If
End Sub
lastrow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = lRow - 1
Loop
fn_LastRow = lRow
End Function
Sub cmdAdd_Click()
BlnVal = 0
Call Data_Validation
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
iCnt = fn_LastRow(Sheets("dtbaseNB")) + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbaseNB")
.Cells(iCnt, 1) = frmNB.txtId.Value
.Cells(iCnt, 2) = frmNB.txt_1.Text
.Cells(iCnt, 3) = frmNB.txt_2.Text
.Cells(iCnt, 4) = frmNB.cbx_3.Text
.Cells(iCnt, 5) = frmNB.txt_4.Text
End With
IdVal = fn_LastRow(Sheets("dtbaseNB"))
frmNB.txtId = Sheet5.Range("A1").Value
ErrOccured:
Application.ScreenUpdating = True
Application.EnableEvents = True
frmNB.txt_1.Value = ""
frmNB.txt_2.Value = ""
frmNB.cbx_3.Value = ""
frmNB.txt_4.Value = ""
frmNB.cmdCancel.SetFocus
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Data_Validation()
flag = True
MsgBox Sheet2.Range("F21").Value & " sudah ada dalam data base, silahkan input Kode baru!",
vbInformation, Sheet2.Range("F21").Value
flag = False
Exit Sub
MsgBox Sheet2.Range("F23").Value & " sudah ada dalam data base, silahkan input Nama baru!",
vbInformation, Sheet2.Range("F23").Value
flag = False
Exit Sub
Exit Sub
Else
BlnVal = 1
End If
End Sub
Unload Me
End Sub
Application.ScreenUpdating = False
frmNB.txt_1.Value = ""
frmNB.txt_2.Value = ""
frmNB.cbx_3.Value = ""
frmNB.txt_4.Value = ""
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
Private Sub ComboBox1_Change()
ListBox1.Value = ComboBox1.Value
End Sub
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
baris = IndexListbox + 1
With Sheets("dtbaseNB")
lDel = MsgBox("Anda yakin akan menghapus data nomor " & ListBox1.Value & "?", vbCritical +
vbYesNo, "Hapus Data")
With Sheets("dtbaseNB")
Application.DisplayAlerts = False
.EntireRow.Delete
Application.DisplayAlerts = True
End With
End With
Else
End If
Application.Calculation = xlCalculationAutomatic
End With
End If
End Sub
ComboBox2.Visible = True
ComboBox2.SetFocus
ComboBox1.Visible = True
ComboBox1.Enabled = False
ComboBox2.BackColor = rgbYellow
cmdSaveE.Visible = True
cmdSaveE.Enabled = True
cmdDel.Visible = True
cmdDel.Enabled = True
txtId.Visible = False
cmdAdd.Visible = False
cmdClear.Enabled = False
End Sub
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
iCnt = IndexListbox + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbaseNB")
.Cells(iCnt, 2) = frmNB.txt_1.Text
.Cells(iCnt, 3) = frmNB.txt_2.Text
.Cells(iCnt, 4) = frmNB.cbx_3.Text
.Cells(iCnt, 5) = frmNB.txt_4.Text
End With
End If
cmdCancel.SetFocus
Application.Calculation = xlCalculationManual
frmNB.txt_1.Value = ""
frmNB.txt_2.Value = ""
frmNB.cbx_3.Value = ""
frmNB.txt_4.Value = ""
cmdDel.Enabled = False
cmdAdd.Enabled = False
cmdSaveE.Enabled = False
Application.Calculation = xlAutomatic
End Sub
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
txtId.Value = ListBox1.List(ListBox1.ListIndex, 0)
txt_1.Text = ListBox1.List(ListBox1.ListIndex, 1)
txt_2.Text = ListBox1.List(ListBox1.ListIndex, 2)
cbx_3.Text = ListBox1.List(ListBox1.ListIndex, 3)
txt_4.Text = ListBox1.List(ListBox1.ListIndex, 4)
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
ComboBox2.Visible = True
ComboBox2.BackColor = rgbYellow
ComboBox1.Value = ComboBox2.ListIndex
cmdSaveE.Visible = True
cmdDel.Visible = True
txtId.Visible = False
cmdAdd.Visible = False
cmdClear.Enabled = False
Call ListBox1_Click
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
If CloseMode = 0 Then
Cancel = True
MsgBox "Tombol X tidak diaktifkan, silahkan klik tombol Close untuk menutup form.", vbCritical
End If
End Sub
KODE FORM PB
'Variable Declaration
IdVal = fn_LastRow(Sheets("dtbasePB"))
'formInput.txtId.Value = IdVal
frmPB.txtId.Value = Sheet5.Range("A3").Value
frmPB.txtId.ForeColor = rgbBlack
frmPB.Caption = Sheet2.Range("D44").Value
If Sheet2.Range("B56").Value = 1 Then
Frame1.ScrollBars = fmScrollBarsNone
frmPB.Height = 434
Frame1.Height = 318
cmdSaveE.Top = 378
cmdDel.Top = 378
cmdAdd.Top = 378
cmdClear.Top = 378
cmdCancel.Top = 378
cmdEdit.Top = 378
Frame1.ScrollBars = fmScrollBarsNone
Frame2.Visible = True
Frame1.ScrollBars = fmScrollBarsVertical
Frame1.ScrollHeight = 500
Frame2.Visible = True
Frame3.Visible = True
End If
End Sub
lastrow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = lRow - 1
Loop
fn_LastRow = lRow
End Function
Sub cmdAdd_Click()
'Boolean Value
BlnVal = 0
'Data Validation
Call Data_Validation
.ScreenUpdating = False
.EnableEvents = False
End With
'Variable declaration
iCnt = fn_LastRow(Sheets("dtbasePB")) + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbasePB")
If Sheet2.Range("B56").Value = 1 Then
'.Cells(iCnt, 1) = iCnt - 1
.Cells(iCnt, 1) = frmPB.txtId.Value
.Cells(iCnt, 2) = frmPB.cbx_tgl.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
.Cells(iCnt, 1) = frmPB.txtId.Value
.Cells(iCnt, 2) = frmPB.cbx_tgl.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
.Cells(iCnt, 2) = frmPB.cbx_tgl.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
End If
frmPB.cmdClear.SetFocus
End With
'Variable declaration
'formInput.txtId = IdVal
frmPB.txtId = Sheet5.Range("A3").Value
ErrOccured:
Application.ScreenUpdating = True
Application.EnableEvents = True
'Application.Calculation = xlAutomatic
frmPB.txt_1.Value = ""
frmPB.cbx_unit.Value = ""
frmPB.cbx_nama1.Value = ""
frmPB.txt_qty1.Value = ""
frmPB.cbx_nama2.Value = ""
frmPB.txt_qty2.Value = ""
frmPB.cbx_nama3.Value = ""
frmPB.txt_qty3.Value = ""
frmPB.cbx_nama4.Value = ""
frmPB.txt_qty4.Value = ""
frmPB.cbx_nama5.Value = ""
frmPB.txt_qty5.Value = ""
frmPB.cbx_nama6.Value = ""
frmPB.txt_qty6.Value = ""
frmPB.cbx_nama7.Value = ""
frmPB.txt_qty7.Value = ""
frmPB.cbx_nama8.Value = ""
frmPB.txt_qty8.Value = ""
frmPB.cbx_nama9.Value = ""
frmPB.txt_qty9.Value = ""
frmPB.cbx_nama10.Value = ""
frmPB.txt_qty10.Value = ""
frmPB.txt_qty10.Value = ""
Frame2.Visible = False
Frame3.Visible = False
'frmNB.Frame1.Enabled = False
frmPB.cmdCancel.SetFocus
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Data_Validation()
frmPB.cbx_tgl.SetFocus
Exit Sub
frmPB.cbx_bln.SetFocus
frmPB.cbx_thn.SetFocus
frmPB.txt_1.SetFocus
frmPB.txt_1.SetFocus
frmPB.cbx_nama1.SetFocus
frmPB.txt_qty1.SetFocus
Else
BlnVal = 1
End If
End Sub
Application.Calculation = xlCalculationManual
Unload Me
ElseIf Sht.Range("A2").Value >= 1 Then
Sht.Range("AU2").Formula = "=DATE(RC[-43],MATCH(RC[-44],bln,0),RC[-45])"
Sht.Range("AV2").Formula = "=RC[-41]&RC3&RC4"
Sht.Range("AW2").Formula = "=RC[-40]&RC3&RC4"
Sht.Range("AX2").Formula = "=RC[-39]&RC3&RC4"
Sht.Range("AY2").Formula = "=RC[-38]&RC3&RC4"
Sht.Range("AZ2").Formula = "=RC[-37]&RC3&RC4"
Sht.Range("BA2").Formula = "=RC[-36]&RC3&RC4"
Sht.Range("BB2").Formula = "=RC[-35]&RC3&RC4"
Sht.Range("BC2").Formula = "=RC[-34]&RC3&RC4"
Sht.Range("BD2").Formula = "=RC[-33]&RC3&RC4"
Sht.Range("BE2").Formula = "=RC[-32]&RC3&RC4"
Sht.Range("BF2").Formula = "=RC[-31]&RC3&RC4"
Sht.Range("BG2").Formula = "=RC[-30]&RC3&RC4"
Sht.Range("BI2").Formula = "=RC[-28]&RC3&RC4"
Sht.Range("BJ2").Formula = "=RC[-27]&RC3&RC4"
Sht.Range("BK2").Formula = "=RC[-26]&RC3&RC4"
Sht.Range("BL2").Formula = "=RC[-25]&RC3&RC4"
Sht.Range("BM2").Formula = "=RC[-24]&RC3&RC4"
Sht.Range("BN2").Formula = "=RC[-23]&RC3&RC4"
Sht.Range("BO2").Formula = "=RC[-22]&RC3&RC4"
End If
Sheet5.Range("E2:E21").ClearContents
Unload Me
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Application.ScreenUpdating = False
'formInput.txtId = Sheet9.Range("A2").Value
frmPB.cbx_tgl.Value = ""
frmPB.cbx_bln.Value = ""
frmPB.cbx_thn.Value = ""
frmPB.txt_1.Value = ""
frmPB.cbx_unit.Value = ""
frmPB.cbx_nama1.Value = ""
frmPB.txt_qty1.Value = ""
frmPB.cbx_nama2.Value = ""
frmPB.txt_qty2.Value = ""
frmPB.cbx_nama3.Value = ""
frmPB.txt_qty3.Value = ""
frmPB.cbx_nama4.Value = ""
frmPB.txt_qty4.Value = ""
frmPB.cbx_nama5.Value = ""
frmPB.txt_qty5.Value = ""
frmPB.cbx_nama6.Value = ""
frmPB.txt_qty6.Value = ""
frmPB.cbx_nama7.Value = ""
frmPB.txt_qty7.Value = ""
frmPB.cbx_nama8.Value = ""
frmPB.txt_qty8.Value = ""
frmPB.cbx_nama9.Value = ""
frmPB.txt_qty9.Value = ""
frmPB.cbx_nama10.Value = ""
frmPB.txt_qty10.Value = ""
frmPB.txt_qty10.Value = ""
Frame2.Visible = False
Frame3.Visible = False
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
ListBox1.Value = ComboBox1.Value
End Sub
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
baris = IndexListbox + 1
With Sheets("dtbasePB")
lDel = MsgBox("Anda yakin akan menghapus data nomor " & ListBox1.Value & "?", vbCritical +
vbYesNo, "Hapus Data")
With Sheets("dtbasePB")
Application.DisplayAlerts = False
.EntireRow.Delete
Application.DisplayAlerts = True
End With
End With
Else
End If
Application.Calculation = xlCalculationAutomatic
End With
End If
End Sub
' ComboBox2.SetFocus
ComboBox1.Visible = True
ComboBox1.BackColor = rgbYellow
cmdSaveE.Visible = True
cmdSaveE.Enabled = True
cmdDel.Visible = True
cmdDel.Enabled = True
txtId.Visible = False
cmdAdd.Visible = False
cmdClear.Enabled = False
'Frame1.Enabled = True
End Sub
Private Sub cmdSaveE_Click()
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
iCnt = IndexListbox + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbasePB")
If Sheet2.Range("B56").Value = 1 Then
'.Cells(iCnt, 1) = iCnt - 1
.Cells(iCnt, 2) = frmPB.cbx_tgl.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
.Cells(iCnt, 2) = frmPB.cbx_tgl.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
.Cells(iCnt, 3) = frmPB.cbx_bln.Value
.Cells(iCnt, 4) = frmPB.cbx_thn.Value
.Cells(iCnt, 5) = frmPB.txt_1.Value
.Cells(iCnt, 6) = frmPB.cbx_unit.Value
.Cells(iCnt, 7) = frmPB.cbx_nama1.Value
.Cells(iCnt, 8) = frmPB.txt_qty1.Value
.Cells(iCnt, 9) = frmPB.cbx_nama2.Value
End If
End With
End If
'Frame1.Enabled = False
cmdCancel.SetFocus
Application.Calculation = xlCalculationManual
frmPB.cbx_tgl.Value = ""
frmPB.cbx_bln.Value = ""
frmPB.cbx_thn.Value = ""
frmPB.txt_1.Value = ""
frmPB.cbx_unit.Value = ""
frmPB.cbx_nama1.Value = ""
frmPB.txt_qty1.Value = ""
frmPB.cbx_nama2.Value = ""
frmPB.txt_qty2.Value = ""
frmPB.cbx_nama3.Value = ""
frmPB.txt_qty3.Value = ""
frmPB.cbx_nama4.Value = ""
frmPB.txt_qty4.Value = ""
frmPB.cbx_nama5.Value = ""
frmPB.txt_qty5.Value = ""
frmPB.cbx_nama6.Value = ""
frmPB.txt_qty6.Value = ""
frmPB.cbx_nama7.Value = ""
frmPB.txt_qty7.Value = ""
frmPB.cbx_nama8.Value = ""
frmPB.txt_qty8.Value = ""
frmPB.cbx_nama9.Value = ""
frmPB.txt_qty9.Value = ""
frmPB.cbx_nama10.Value = ""
frmPB.txt_qty10.Value = ""
Frame2.Visible = False
Frame3.Visible = False
cmdDel.Enabled = False
cmdAdd.Enabled = False
cmdSaveE.Enabled = False
Application.Calculation = xlAutomatic
End Sub
Application.Calculation = xlCalculationManual
txtId.Value = ListBox1.List(ListBox1.ListIndex, 0)
cbx_tgl.Value = ListBox1.List(ListBox1.ListIndex, 1)
cbx_bln.Value = ListBox1.List(ListBox1.ListIndex, 2)
cbx_thn.Value = ListBox1.List(ListBox1.ListIndex, 3)
txt_1.Value = ListBox1.List(ListBox1.ListIndex, 4)
cbx_unit.Value = ListBox1.List(ListBox1.ListIndex, 5)
cbx_nama1.Value = ListBox1.List(ListBox1.ListIndex, 6)
txt_qty1.Value = ListBox1.List(ListBox1.ListIndex, 7)
cbx_nama2.Value = ListBox1.List(ListBox1.ListIndex, 8)
txt_qty2.Value = ListBox1.List(ListBox1.ListIndex, 9)
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
Sheet5.Range("E2").Value = cbx_nama1.Value
Sheet5.Range("F2").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan1.Value = Sheet5.Range("F2").Value
Sheet5.Range("G2").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode1.Value = Sheet5.Range("G2").Value
End Sub
Sheet5.Range("E3").Value = cbx_nama2.Value
Sheet5.Range("F3").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan2.Value = Sheet5.Range("F3").Value
Sheet5.Range("G3").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode2.Value = Sheet5.Range("G3").Value
End Sub
Sheet5.Range("E4").Value = cbx_nama3.Value
Sheet5.Range("F4").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan3.Value = Sheet5.Range("F4").Value
Sheet5.Range("G4").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode3.Value = Sheet5.Range("G4").Value
End Sub
Private Sub cbx_nama4_Change()
Sheet5.Range("E5").Value = cbx_nama4.Value
Sheet5.Range("F5").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan4.Value = Sheet5.Range("F5").Value
Sheet5.Range("G5").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode4.Value = Sheet5.Range("G5").Value
End Sub
Sheet5.Range("E6").Value = cbx_nama5.Value
Sheet5.Range("F6").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan5.Value = Sheet5.Range("F6").Value
Sheet5.Range("G6").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode5.Value = Sheet5.Range("G6").Value
End Sub
Sheet5.Range("E7").Value = cbx_nama6.Value
Sheet5.Range("F7").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan6.Value = Sheet5.Range("F7").Value
Sheet5.Range("G7").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode6.Value = Sheet5.Range("G7").Value
End Sub
Sheet5.Range("E8").Value = cbx_nama7.Value
Sheet5.Range("F8").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan7.Value = Sheet5.Range("F8").Value
Sheet5.Range("G8").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode7.Value = Sheet5.Range("G8").Value
End Sub
Sheet5.Range("E9").Value = cbx_nama8.Value
Sheet5.Range("F9").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan8.Value = Sheet5.Range("F9").Value
Sheet5.Range("G9").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode8.Value = Sheet5.Range("G9").Value
End Sub
Sheet5.Range("E10").Value = cbx_nama9.Value
Sheet5.Range("F10").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan9.Value = Sheet5.Range("F10").Value
Sheet5.Range("G10").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode9.Value = Sheet5.Range("G10").Value
End Sub
Sheet5.Range("E11").Value = cbx_nama10.Value
Sheet5.Range("F11").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan10.Value = Sheet5.Range("F11").Value
Sheet5.Range("G11").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode10.Value = Sheet5.Range("G11").Value
End Sub
Sheet5.Range("E12").Value = cbx_nama11.Value
Sheet5.Range("F12").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan11.Value = Sheet5.Range("F12").Value
Sheet5.Range("G12").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode11.Value = Sheet5.Range("G12").Value
End Sub
Sheet5.Range("E13").Value = cbx_nama12.Value
Sheet5.Range("F13").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan12.Value = Sheet5.Range("F13").Value
Sheet5.Range("G13").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode12.Value = Sheet5.Range("G13").Value
End Sub
Sheet5.Range("E14").Value = cbx_nama13.Value
Sheet5.Range("F14").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan13.Value = Sheet5.Range("F14").Value
Sheet5.Range("G14").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode13.Value = Sheet5.Range("G14").Value
End Sub
Sheet5.Range("E15").Value = cbx_nama14.Value
Sheet5.Range("F15").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan14.Value = Sheet5.Range("F15").Value
Sheet5.Range("G15").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode14.Value = Sheet5.Range("G15").Value
End Sub
Sheet5.Range("E16").Value = cbx_nama15.Value
Sheet5.Range("F16").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan15.Value = Sheet5.Range("F16").Value
Sheet5.Range("G16").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode15.Value = Sheet5.Range("G16").Value
End Sub
Sheet5.Range("E17").Value = cbx_nama16.Value
Sheet5.Range("F17").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan16.Value = Sheet5.Range("F17").Value
Sheet5.Range("G17").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode16.Value = Sheet5.Range("G17").Value
End Sub
Sheet5.Range("E18").Value = cbx_nama17.Value
Sheet5.Range("F18").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan17.Value = Sheet5.Range("F18").Value
Sheet5.Range("G18").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode17.Value = Sheet5.Range("G18").Value
End Sub
Sheet5.Range("E19").Value = cbx_nama18.Value
Sheet5.Range("F19").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan18.Value = Sheet5.Range("F19").Value
Sheet5.Range("G19").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode18.Value = Sheet5.Range("G19").Value
End Sub
Sheet5.Range("E20").Value = cbx_nama19.Value
Sheet5.Range("F20").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan19.Value = Sheet5.Range("F20").Value
Sheet5.Range("G20").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode19.Value = Sheet5.Range("G20").Value
End Sub
Sheet5.Range("E21").Value = cbx_nama20.Value
Sheet5.Range("F21").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan20.Value = Sheet5.Range("F21").Value
Sheet5.Range("G21").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode20.Value = Sheet5.Range("G21").Value
End Sub
If CloseMode = 0 Then
Cancel = True
MsgBox "Tombol X tidak diaktifkan, silahkan klik tombol Close untuk menutup form.", vbCritical
End If
End Sub
KODE FORM SB
'Variable Declaration
IdVal = fn_LastRow(Sheets("dtbaseSB"))
'formInput.txtId.Value = IdVal
frmSB.txtId.Value = Sheet5.Range("A2").Value
frmSB.txtId.ForeColor = rgbBlack
frmSB.Caption = Sheet2.Range("D30").Value
txt_1.Visible = True
lbl_4.Visible = False
txt_1.Visible = False
End If
lbl_5.Visible = True
txt_2.Visible = True
lbl_5.Visible = False
txt_2.Visible = False
End If
lbl_6.Visible = True
txt_3.Visible = True
lbl_6.Visible = False
txt_3.Visible = False
End If
End Sub
lastrow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = Sht.Cells.SpecialCells(xlLastCell).Row
lRow = lRow - 1
Loop
fn_LastRow = lRow
End Function
Sub cmdAdd_Click()
'Boolean Value
BlnVal = 0
'Data Validation
Call Data_Validation
.ScreenUpdating = False
.EnableEvents = False
End With
'Variable declaration
Dim txtId, cbx_tgl, cbx_bln, cbx_thn, cbx_namaB, txt_qty, txt_1, txt_2, txt_3
iCnt = fn_LastRow(Sheets("dtbaseSB")) + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbaseSB")
.Cells(iCnt, 1) = frmSB.txtId.Value
.Cells(iCnt, 2) = frmSB.cbx_tgl.Value
.Cells(iCnt, 3) = frmSB.cbx_bln.Value
.Cells(iCnt, 4) = frmSB.cbx_thn.Value
.Cells(iCnt, 5) = frmSB.cbx_namaB.Value
.Cells(iCnt, 6) = frmSB.txt_qty.Value
.Cells(iCnt, 9) = frmSB.txt_3.Value
frmSB.cmdClear.SetFocus
End With
'Variable declaration
IdVal = fn_LastRow(Sheets("dtbaseSB"))
'formInput.txtId = IdVal
frmNB.txtId = Sheet5.Range("A2").Value
ErrOccured:
Application.ScreenUpdating = True
Application.EnableEvents = True
frmSB.cbx_namaB.Value = ""
frmSB.txt_qty.Value = ""
frmSB.txt_1.Value = ""
frmSB.txt_2.Value = ""
frmSB.txt_3.Value = ""
frmSB.cmdCancel.SetFocus
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Sub Data_Validation()
If frmSB.cbx_tgl = "" Then
frmSB.cbx_tgl.SetFocus
Exit Sub
frmSB.cbx_bln.SetFocus
frmSB.cbx_thn.SetFocus
frmSB.cbx_namaB.SetFocus
frmSB.txt_qty.SetFocus
Else
BlnVal = 1
End If
End Sub
Unload Me
Sht.Range("J2").Formula = "=DATE(RC[-6],MATCH(RC[-7],bln,0),RC[-8])"
Sht.Range("K2").Formula = "=RC[-6]&RC[-8]&RC[-7]"
End If
Sheet5.Range("E1").ClearContents
Unload Me
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Application.ScreenUpdating = False
'formInput.txtId = Sheet9.Range("A2").Value
frmSB.cbx_tgl.Value = ""
frmSB.cbx_bln.Value = ""
frmSB.cbx_thn.Value = ""
frmSB.cbx_namaB.Value = ""
frmSB.txt_qty.Value = ""
frmSB.txt_1.Value = ""
frmSB.txt_2.Value = ""
frmSB.txt_3.Value = ""
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
ListBox1.Value = ComboBox1.Value
End Sub
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
baris = IndexListbox + 1
With Sheets("dtbaseSB")
lDel = MsgBox("Anda yakin akan menghapus data nomor " & ListBox1.Value & "?", vbCritical +
vbYesNo, "Hapus Data")
With Sheets("dtbaseSB")
Application.DisplayAlerts = False
.EntireRow.Delete
Application.DisplayAlerts = True
End With
End With
Else
End If
End With
End If
Application.Calculation = xlCalculationAutomatic
End Sub
ComboBox2.Visible = True
ComboBox2.SetFocus
ComboBox1.Visible = True
ComboBox1.Enabled = False
ComboBox2.BackColor = rgbYellow
cmdSaveE.Visible = True
cmdSaveE.Enabled = True
cmdDel.Visible = True
cmdDel.Enabled = True
txtId.Visible = False
cmdAdd.Visible = False
cmdClear.Enabled = False
'Frame1.Enabled = True
End Sub
Private Sub cmdSaveE_Click()
Application.Calculation = xlCalculationManual
If Me.ListBox1.ListIndex = -1 Then
IndexListbox = Me.ListBox1.ListIndex
iCnt = IndexListbox + 1
Application.Calculation = xlCalculationManual
With Sheets("dtbaseSB")
.Cells(iCnt, 2) = frmSB.cbx_tgl.Value
.Cells(iCnt, 3) = frmSB.cbx_bln.Value
.Cells(iCnt, 4) = frmSB.cbx_thn.Value
.Cells(iCnt, 5) = frmSB.cbx_namaB.Value
.Cells(iCnt, 6) = frmSB.txt_qty.Value
.Cells(iCnt, 9) = frmSB.txt_3.Value
End With
End If
Application.Calculation = xlCalculationManual
frmSB.cbx_tgl.Value = ""
frmSB.cbx_bln.Value = ""
frmSB.cbx_thn.Value = ""
frmSB.cbx_namaB.Value = ""
frmSB.txt_qty.Value = ""
frmSB.txt_1.Value = ""
frmSB.txt_2.Value = ""
frmSB.txt_3.Value = ""
cmdDel.Enabled = False
cmdAdd.Enabled = False
cmdSaveE.Enabled = False
Application.Calculation = xlAutomatic
cmdCancel.SetFocus
End Sub
Application.Calculation = xlCalculationManual
txtId.Value = ListBox1.List(ListBox1.ListIndex, 0)
cbx_tgl.Value = ListBox1.List(ListBox1.ListIndex, 1)
cbx_bln.Value = ListBox1.List(ListBox1.ListIndex, 2)
cbx_thn.Value = ListBox1.List(ListBox1.ListIndex, 3)
cbx_namaB.Value = ListBox1.List(ListBox1.ListIndex, 4)
txt_qty.Value = ListBox1.List(ListBox1.ListIndex, 5)
txt_3.Value = ListBox1.List(ListBox1.ListIndex, 8)
Application.Calculation = xlCalculationAutomatic
End Sub
'Application.ScreenUpdating = False
'Application.Calculation = xlCalculationManual
ComboBox2.Visible = True
ComboBox2.BackColor = rgbYellow
ComboBox1.Value = ComboBox2.ListIndex
cmdSaveE.Visible = True
cmdDel.Visible = True
txtId.Visible = False
cmdAdd.Visible = False
cmdClear.Enabled = False
Call ListBox1_Click
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
Application.Calculation = xlCalculationManual
Sheet5.Range("E1").Value = cbx_namaB.Value
Sheet5.Range("F1").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],dtbaseNB!C[-3]:C[-
2],2,FALSE),"""")"
txt_satuan.Value = Sheet5.Range("F1").Value
Sheet5.Range("G1").FormulaR1C1 = "=IFERROR(OFFSET(dtbaseNB!R1C1,MATCH('R'!RC[-
2],Nama_Barang,0)-1,1),"""")"
txt_kode.Value = Sheet5.Range("G1").Value
Application.Calculation = xlCalculationAutomatic
End Sub
Exit Sub
ABC:
txt_1 = ""
End Sub
Exit Sub
ABC:
txt_2 = ""
End Sub
If CloseMode = 0 Then
Cancel = True
MsgBox "Tombol X tidak diaktifkan, silahkan klik tombol Close untuk menutup form.", vbCritical
End If
End Sub
KODE MODULE
Sub Auto_Open()
Form_Login.Show
End Sub
Sub Workbook_Activate()
End Sub
Sub Workbook_Deactivate()
End Sub
Sub FormNB_Show()
frmNB.Show (vbModeless)
End Sub
Sub FormSB_Show()
frmSB.Show (vbModeless)
End Sub
Sub FormPB_Show()
frmPB.Show (vbModeless)
End Sub
Sub Preview_()
End Sub
Sub Print_()
Dim ws As Worksheet
Set ws = ActiveSheet
, AllowFormattingColumns:=True, AllowFormattingRows:=True
ActiveWindow.DisplayHeadings = False
End Sub
Sub EditKol_NT()
, AllowFormattingColumns:=True, AllowFormattingRows:=True
ActiveWindow.DisplayHeadings = True
Range("F13").Select
End Sub
Sub OK_()
Dim ws As Worksheet
Set ws = ActiveSheet
, AllowFormattingColumns:=True, AllowFormattingRows:=True
ActiveWindow.DisplayHeadings = False
End Sub
Sub ubah_()
Dim ws As Worksheet
Set ws = ActiveSheet
ActiveWindow.DisplayHeadings = False
End Sub
Sub O_()
Dim ws As Worksheet
Set ws = ActiveSheet
, AllowFormattingColumns:=True, AllowFormattingRows:=True
End Sub