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
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