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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,215,876
Messages
6,127,482
Members
449,385
Latest member
KMGLarson

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
Back
Top