ListBox with keydown event

nidhipatel

Board Regular
Joined
Feb 11, 2017
Messages
52
My userform contain 6 TextBox (TextBox1 To TextBox6)
listBox1
3 macro contain
1 – TextBox Data Transfer To Listbox
2 – Dobule Clcik To Listobx For Edit ListBox Data and show in Reseptivly Textboxs
3 - Update Data Show in ListBox

Macro 1

Is run in Textbox6 KeyDown Event If Key Code = 13 then data Transfer to Listbox)

Macro 3

Is also run in Textbox6 KeyDown Event If Key Code = 13 then updated data show in listbox



In short macro 1 and macro 3 both is run in textbox 6 Keydown event

My code I below given error how it fix

Private Sub TextBox6_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

Dim i As Integer

With UserForm1

For i = 1 To .ListBox1.ListCount - 1
If .ListBox1.Selected(i) And KeyCode = 13 Then

.ListBox1.List(i, 0) = .TextBox1
.ListBox1.List(i, 1) = .TextBox2
.ListBox1.List(i, 2) = .TextBox3
.ListBox1.List(i, 3) = .TextBox4
.ListBox1.List(i, 4) = .TextBox5
.ListBox1.List(i, 5) = .TextBox6

Else

Call Module3.TextBox_Data_To_List_Box
End If
Next i
End With
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,144,566
Messages
5,725,021
Members
422,589
Latest member
JohnnyBravo1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top