Selamat siang rekan-rekan,
Saat ini saya sedang membuat sistem input untuk kantor menggunakan macro-vba, tetapi terkendala prosedur yg dibuat terlalu panjang sehingga membatasi jumlah inputan.
Mohon saran bagaimana cara untuk menyingkat prosedur/perintah berulah pada macro yg saya buat di bawah ini:
Total Combobox ada 160, Textbox 80
If ComboBox1 <> "Kode1" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox1.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox2.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox1.Value ActiveCell.Offset(1, -4).Select End If If ComboBox3 <> "Kode2" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox3.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox4.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox2.Value ActiveCell.Offset(1, -4).Select End If If ComboBox5 <> "Kode3" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox5.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox6.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox3.Value ActiveCell.Offset(1, -4).Select End If If ComboBox7 <> "Kode4" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox7.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox8.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox4.Value ActiveCell.Offset(1, -4).Select End If If ComboBox9 <> "Kode5" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox9.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox10.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox5.Value ActiveCell.Offset(1, -4).Select End If If ComboBox11 <> "Kode6" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox11.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox12.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox6.Value ActiveCell.Offset(1, -4).Select End If If ComboBox13 <> "Kode7" Then ActiveCell.FormulaR1C1 = CboBln.Value & "/" & CboTgl.Value & "/" & CboThn.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TxtPO.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = CboToko.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox13.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = ComboBox14.Value ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = TextBox7.Value ActiveCell.Offset(1, -4).Select End If
Terima kasih atas bantuannya