Hello,
After hours of countless related threads, I still cannot discover ways to vlookup with userform's textboxes to display information from a separate sheet based on a vlookup reference inside another textbox.
I'll simplify things;
A button is pressed on a sheet named "input";
the following form pops up;
The only input required from the user is the "Agent ID:" text box (named txtid). I need txtid to be my vlookup reference. The remaining fields should autocomplete (Agent Name:, Team Leader:, LOB.
The information is then sent to a sheet named "data_coaching";
The information should be vlookup'ed from a separate sheet named "agent_data" seen here:
I also have a combobox ("Submitter:") that should pull info from a sheet named "staff". Column A contains a list of employees and Column B contains a second list. The checkbox ("CCR") should, when TRUE, switch from A to B.
Nothing I have tried will work mainly due to my extreme lack of VBA knowledge.
Would this code be placed in a module? the form itself?
Can anyone shed some light on vlookups, userforms and comboboxes?
PS - the cake IS a lie!
After hours of countless related threads, I still cannot discover ways to vlookup with userform's textboxes to display information from a separate sheet based on a vlookup reference inside another textbox.
I'll simplify things;
A button is pressed on a sheet named "input";
Code:
Sub clickme()
coaching.Show False
End Sub
the following form pops up;
The only input required from the user is the "Agent ID:" text box (named txtid). I need txtid to be my vlookup reference. The remaining fields should autocomplete (Agent Name:, Team Leader:, LOB.
The information is then sent to a sheet named "data_coaching";
Code:
Option Explicit
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("coaching_data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'error on blank id
If Trim(Me.txtid.Value) = "" Then
Me.txtid.SetFocus
MsgBox "Something went wrong. The cake is a lie!"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 2).Value = Me.txtid.Value
ws.Cells(iRow, 3).Value = Me.txtname.Value
ws.Cells(iRow, 4).Value = Me.txttl.Value
ws.Cells(iRow, 5).Value = Me.txtlob.Value
'clear the data
Me.txtid.Value = ""
Me.txtname.Value = ""
Me.txttl.Value = ""
Me.txtlob.Value = ""
Me.txtid.SetFocus
End Sub
Private Sub cmdReset_Click()
'clear the data
Me.txtid.Value = ""
Me.txtname.Value = ""
Me.txttl.Value = ""
Me.txtlob.Value = ""
Me.txtid.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
The information should be vlookup'ed from a separate sheet named "agent_data" seen here:
I also have a combobox ("Submitter:") that should pull info from a sheet named "staff". Column A contains a list of employees and Column B contains a second list. The checkbox ("CCR") should, when TRUE, switch from A to B.
Nothing I have tried will work mainly due to my extreme lack of VBA knowledge.
Would this code be placed in a module? the form itself?
Can anyone shed some light on vlookups, userforms and comboboxes?
PS - the cake IS a lie!