Editing data from another sheet using Combobox?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
Happy Friday!

Today I'm trying to give users the ability to edit data on a sheet using a userform.

Here's a screen shot...

edit garage.png


Here's my code:

VBA Code:
Private Sub cmdUpdateGarageHandling_Click()
Dim EditGarageHandling_id As String
EditGarageHandling = Trim(EditGarageHandling.Text)
LastRow = Worksheets("GarageHandling").Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
If Worksheets("GarageHandling").Cells(i, 1).Value = EditGarageHandling Then
   Worksheets("GarageHandling").Cells(i, 1).Value = EditGarageHandling.Text
End If
Next
        
        Call cmdResetDeleteGarageHandling_Click
        
        MsgBox ("Garage Handling Successfully Updated!")

End Sub

The user would select data from the combobox, make changes and hit update to edit the data in sheet (GarageHandling).

The current code doesn't error out, but it doesn't edit anything either.
 
Do you have any code in the initialise event that puts a value into the combo?

I have this:

VBA Code:
    Set wsGarageHandling = ThisWorkbook.Worksheets("GarageHandling")
    EditGarageHandling.List = [GarageHandling!GarageHandling].Value
    EditGarageHandlingReturn.Visible = False
    LabelEditGH.Visible = False
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Ok, that should put the list of values back into the combo, so what exactly is not working?
 
Upvote 0
Ok, that should put the list of values back into the combo, so what exactly is not working?

When I edit the data and click Update, Call cmdResetDeleteGarageHandling_Click successfully clears the list box but not the combobox.

VBA Code:
Private Sub cmdResetDeleteGarageHandling_Click()
        With Me
            .EditGarageHandling.Clear
            .EditGarageHandlingReturn.Value = ""
        End With
        UserForm_Initialize
        EditGarageHandling.SetFocus
        Me.cmdDeleteModel.Enabled = False
End Sub
 
Upvote 0
What do you mean by it doesn't clear the combo? That code is removing the list in the combo, but then you are putting the list back in on the initialise event.
 
Upvote 0
What do you mean by it doesn't clear the combo? That code is removing the list in the combo, but then you are putting the list back in on the initialise event.

Hope this helps:

Before...
edit garage A.png


Select...
edit garage B.png


Edit...
edit garage C.png


Click Update, but reset doesn't clear combobox. Original unedited data remains...
edit garage D.png
 
Upvote 0
I have no idea why that is happening. Assuming that combo is called EditGarageHandling then this line of code should clear everything from the list.
VBA Code:
.EditGarageHandling.Clear
 
Upvote 0
I have no idea why that is happening. Assuming that combo is called EditGarageHandling then this line of code should clear everything from the list.
VBA Code:
.EditGarageHandling.Clear

Here's the strange part: If I select data and hit reset without editing it clears fine.
 
Upvote 0
Try removing this line
VBA Code:
EditGarageHandling = Trim(EditGarageHandling.Text)
 
Upvote 0
You were changing the value of the combo, to a value that is not in the list.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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