Below VBA Code is working fine if FindVal is a Text value.
1. Working For String Value
Private Sub FDACNo_Change()
Dim myRange As Range
Set myRange = Worksheets("FD Accounts").Range("FDAccountData")
On Error Resume Next
FindVal = FDACNo
Names.Value = Application.WorksheetFunction.VLookup(FindVal, myRange, 2, False)
If err.Number <> 0 Then Names.Value = ""
End Sub
Afterthat I changed this code (Diclare Dim FindVal as Long) to use this code for Numeric Value. Like below.
2. Not Working For Numerical Values
Private Sub FDACNo_Change()
Dim myRange As Range
Dim FindVal As Long
Set myRange = Worksheets("FD Accounts").Range("FDAccountData")
On Error Resume Next
FindVal = FDACNo
Names.Value = Application.WorksheetFunction.VLookup(FindVal, myRange, 2, False)
If err.Number <> 0 Then Names.Value = ""
End Sub
But it gives me an Object Required Error Message.
Note: FDACNo and Names are name of two TextBox fields in a UserFor.
FDACNo is a numerical value, so I used CStr(FindVal) to convert it to a String Value like this:
Names.Value = Application.WorksheetFunction.VLookup(CStr(FindVal), myRange, 2, False)
But no luck
Please Help.