Edit/Update listbox and activeworksheet

campB

New Member
Joined
Aug 20, 2019
Messages
2
Hello. I am new here and am hoping someone can help me.

I have a userform (Userform1)
which has 2 comboboxes, 4 textboxes, 1 listbox and a few commandbuttons.

I have the userform working well except for the edit and update buttons.
The edit and update buttons are only for the search part of the userform. I was setting it up so that the user, if he/she made a mistake can click on the cbosearch button which loads the activeworksheets data into the listbox (Listbox1). He/she would then select the row from the listbox, then Clicking on the edit button will load each column into the appropriate comboboxes and textboxes. after editting/changing the fault, the update button will be clicked saving the same rowsource data, well that"s what i want to happen. This is not happening for me.

The code below is for the edit button and update button.

Private Sub btnEdit_Click()
'ClearControls
ActiveWorkbook.ActiveSheet.Range("A2").Select
If Me.ListBox1.ListIndex = -1 Then 'not selected
MsgBox " No selection made"
ElseIf Me.ListBox1.ListIndex >= 1 Then 'User has selected
i = Me.ListBox1.ListIndex
With Me
.cboCategory.Text = ListBox1.List(i, 0)
.cboOutlet.Text = ListBox1.List(i, 1)
.txtRecieptNo.Text = ListBox1.List(i, 2)
.txtAmount.Text = ListBox1.List(i, 3)
.txtDate.Text = ListBox1.List(i, 4)
.txtOtherInfo.Text = ListBox1.List(i, 5)
ListBox1.ListIndex = 0
End With
End If
End Sub
This seems to be working fine.


Private Sub cmdUpdate_Click()
ListBox1.List(i, 0) = cboCategory.Value
ListBox1.List(i, 1) = cboOutlet.Value
ListBox1.List(i, 2) = txtRecieptNo.Value
ListBox1.List(i, 3) = txtAmount.Value
ListBox1.List(i, 4) = txtDate.Value
ListBox1.List(i, 5) = txtOtherInfo.Value
Exit For
Next y
Call myNew
End Sub
This is where i have been stumbling. I've got the listbox updating, but cannot figure out the code to update the activeworksheet.
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Watch MrExcel Video

Forum statistics

Threads
1,099,574
Messages
5,469,475
Members
406,655
Latest member
pwilson06

This Week's Hot Topics

Top