Updating a dynamic table using a VBA userform

rmcanada

New Member
Joined
Jul 9, 2014
Messages
2
Hi there, I have a sample of a more complex database that I am looking to automate with some VBA adjustments. I am new to VBA and would greatly appreciate some help with my work. I am using Excel 2010.

I have a userform made of a textbox for the new updated position, a combobox which selects the employee subject to update, and a submit button. The purpose of the userform is to change the position (textbox1) based upon the employee selected by number (combobox1). I have successfully coded a dynamic combobox list, but I cannot seem to add a textbox to change the position of the selected employee. The updated position will be the textbox1.value entered before the submit button.

If anyone can help, please try! Thank you in advance.

- Ryan

Number....Name.......Position
1............Michael.....Boss
2............John.........Trainee
3............Scott........Part-Time
4............Lisa..........Clerk


Code:
Private Sub UserForm_Initialize() 
'populate combobox
With Worksheets(1)
    ComboBox1.List = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value
End With
End Sub

Private Sub CommandButton1_Click() 

Dim example As Range
With Worksheets("Sheet1")
Set example = Range("A2:B" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With

With Me
    .cells(ComboBox1.Value,worksheetfunction.VLookup(ComboBox1.Value,example.Range,2,FALSE).value = textbox1.Value)
End With

End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

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