jeudi 16 janvier 2020

how to retrieve check of checkbox after clicking listbox_click() in excel VBA

enter image description here

As seen in the picture, what it would like to happen, when listbox is click it would retrieve the check of checkbox from the worksheet.

Private Sub ListBox1_Click()
Dim say, lastrow As Long

TextBox15 = ListBox1.Column(0) TextBox18 = ListBox1.Column(1) TextBox1 = ListBox1.Column(2) TextBox2 = ListBox1.Column(3) TextBox19 = ListBox1.Column(4) TextBox3 = ListBox1.Column(5) TextBox24 = ListBox1.Column(6) TextBox26 = ListBox1.Column(7) TextBox5 = ListBox1.Column(8) TextBox6 = ListBox1.Column(9) TextBox7 = ListBox1.Column(10) TextBox8 = ListBox1.Column(11) TextBox23 = ListBox1.Column(12) TextBox22 = ListBox1.Column(13) TextBox4 = ListBox1.Column(14) TextBox21 = ListBox1.Column(15) TextBox20 = ListBox1.Column(16) TextBox11 = ListBox1.Column(17) TextBox12 = ListBox1.Column(18) TextBox13 = ListBox1.Column(19) TextBox14 = ListBox1.Column(20) TextBox27 = ListBox1.Column(21) TextBox28 = ListBox1.Column(22) TextBox29 = ListBox1.Column(23) TextBox25 = ListBox1.Column(24) TextBox30 = ListBox1.Column(25) TextBox31 = ListBox1.Column(26) TextBox32 = ListBox1.Column(27) TextBox33 = ListBox1.Column(28) CheckBox1 = ListBox1.Column(29) CheckBox2 = ListBox1.Column(30) CheckBox3 = ListBox1.Column(31) CheckBox4 = ListBox1.Column(32) CheckBox5 = ListBox1.Column(33) CheckBox6 = ListBox1.Column(34) CheckBox7 = ListBox1.Column(35) CheckBox8 = ListBox1.Column(36) CheckBox9 = ListBox1.Column(37) CheckBox10 = ListBox1.Column(38) CheckBox11 = ListBox1.Column(39) CheckBox12 = ListBox1.Column(40) CheckBox13 = ListBox1.Column(41)

lastrow = Sheets("liste").Cells(Rows.Count, "D").End(xlUp).Row Set sonsati = Sheets("liste").Range("D2:D" & lastrow).Find(What:=TextBox1.Text, LookIn:=xlValues, LookAt:=xlWhole) say = sonsati.Row Sheets("liste").Range("A" & say & ":AD" & say).Select

CommandButton1.Enabled = False CommandButton2.Enabled = True CommandButton3.Enabled = True End Sub

I tried above formula but i always promted with an error of "Run-time error '-2147024809', could not get the column property. Invalid argument.

Can someone please help me.

thank You in Advance




Aucun commentaire:

Enregistrer un commentaire