I don’t know why this happening but i get it when i try to update a list box value.my intention was to use two textboxes to get listbox values of colum 0 and 1 after double click then change values in textboxes and click update “commandbutton1” to change the value. ultimately i want to send the changes to the spreadsheet to update the table where the listbox is getting its values from.
Thank you so much in advance for any help you can provide. i spend hours trying things but nothing want to work.
here is my code:
Private Sub CommandButton1_Click() ‘code to update listbox after cahnging values in textboxes If ListBox1.ListIndex -1 Then With ListBox1 .List(.ListIndex, 0) = txtDepartment.Value .List(.ListIndex, 1) = txtType.Value End With End If End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) ‘code to get listbox column o and 1 to textboxes in the same form Label3.Visible = True Label4.Visible = True txtDepartment.Visible = True txtType.Visible = True UserForm3.txtDepartment.Text = ListBox1.List(ListBox1.ListIndex) UserForm3.txtType.Text = ListBox1.List(ListBox1.ListIndex, 1) End Sub Private Sub UserForm_Initialize() ‘Puts the user form in the middle of the Excel screen when opened. Me.StartupPosition = 0 Me.Top = (Application.Height / 2) – (Me.Height / 2) Me.Left = (Application.Width / 2) – (Me.Width / 2) ‘populate list boxes with dynamic ranges ListBox1.RowSource = “GLDepartment” ListBox2.RowSource = “ExpenseType” txtDepartment.Visible = False txtType.Visible = False Label3.Visible = False Label4.Visible = False End Sub