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)
AF1QipNHSjnJqAT1vTI6y3EMT3WFrNKmBvgHeSTB8qMaACKU5W2L0khFiPwU4q3tvbPOCw
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.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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