Input Nilai Pada Listbox Teknozia – Langsung saja berikut ini cara membuat input nilai pada listbox secara manual. Buka microsoft excel, simpan dengan enable macro atau format Xlsb Tekan ALT+F11 untuk masuk ke jendela microsoft visual basic editor (VBE/VBA) Tambahkan userform, dengan empat textbox, satu commandbutton dan satu listbox, lihat gambar dibawah ini : Klik dua kali pada userform, buat sub header listbox “cara membuat header listbox”
Model Form Sub Headerlist() With ListBox1 .AddItem .List(.ListCount – 1, 0) = “Nomor” .List(.ListCount – 1, 1) = “Nama Siswa” .List(.ListCount – 1, 2) = “Kelas”
.List(.ListCount – 1, 3) = “Wali murid” .ColumnWidths = 35 & “;” & 70 & “;” & 45 & “;” & 80 End With End Sub Setelahnya buat kode macro pada event Commandbutton click Private Sub CommandButton1_Click() With ListBox1 .AddItem .List(.ListCount – 1, 0) = TextBox1.Value .List(.ListCount – 1, 1) = TextBox2.Value .List(.ListCount – 1, 2) = TextBox3.Value .List(.ListCount – 1, 3) = TextBox4.Value End With End Sub Buat kode macro pada event userform active Private Sub UserForm_Activate() Call Headerlist End Sub Pengaturan pada jumlah kolom listbox
Pengaturan ListBox Tekan F5 untuk meccoba berhasil atau tidak. Lihat pada simulasi berikut ini
Form Jadi Demikianlah tutorial cara Input nilai pada listbox pada pertemuan hari ini, Semoga bermanfaat, bagi yang ingin belajar excel visual basic editor (VBE/VBA) bisa langsung standbay disini. terimakasih