Hi there,
I trying to setup a VLOOKUP in a Userform.
[vba]
Dim nlook as Variant
Dim dLook As Variant
Dim sLook As Variant
Set ws = Worksheets("Lookups")
nLook = Application.VLookup(Me.txtDealerNo.Value, ws.Range("V14:X1033"), 1, True)
dLook = Application.VLookup(Me.txtDealerNo.Value, ws.Range("V14:X1033"), 2, True)
sLook = Application.VLookup(Me.txtDealerNo.Value, ws.Range("V14:X1033"), 3, True)
[/vba]
Now, when the user enters the dealer number in a particular field it should then populate other fields :
[vba]
Private Sub txtDealerNoSendTo_Change()
Call sDName
End Sub
Private Sub txtDealerNoSendTo_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Call sDName
End Sub
Private Sub sDName()
If Me.txtDealerNo.Value = nLook Then
Me.txtDealerName.Value = dLook
ElseIf Me.txtDealerNo.Value = "" Then
Me.txtDealerName.Value = ""
End If
End Sub
[/vba]
Where am I goinf wrong as when I enter a number into the field nothing happens. Would any be able to point me in the right direction.
Thanks,