BarefootPaul
Board Regular
- Joined
- Jul 21, 2011
- Messages
- 54
I am trying to populate a text box on a userform using vlookup (not sure if this is the best way). I use a combobox on another userform to populate the txtMaineCare.Value (txtMaineCare.Value = cboLookup.Value) and then want the values for txtFName, txtLName and txtDOB to be populated by the values that correspond. Is there a way to set these other values by using something like cboLookup.Value.Column2 or can only the bound column's value be returned?
Here is the code:
When I run it, I get an error:
Run-time error '-2147352571 (80020005)': Could not set the Value Property. Type mismatch.
Thanks
Here is the code:
Code:
Private Sub txtMaineCare_Change()
Dim vLook As Range
With ActiveWorkbook.Sheets("Clients")
Set vLook = .Range("A:D")
txtFName.Value = Application.VLookup(txtMaineCare.Value, vLook, 2, False)
txtLName.Value = Application.VLookup(txtMaineCare.Value, vLook, 3, False)
txtDOB.Value = Application.VLookup(txtMaineCare.Value, vLook, 4, False)
txtDOA.SetFocus
End With
End Sub
When I run it, I get an error:
Run-time error '-2147352571 (80020005)': Could not set the Value Property. Type mismatch.
Thanks