beetle_cca
New Member
- Joined
- Aug 11, 2014
- Messages
- 6
Hi All,
Very much a novice when it comes to VBA. Thank you in advance.
I have a userform where the user inserts a contract number the clicks on a command button to extract data from a master list. This is all working great, hoever I have tried to handle errors when an unmatch value is entered. The msgbox appears and the user is taken back to the form however when they enter a correct value the "cusname" is not populated.
Any help would be amazing.
Private Sub Userform_Extract()
Dim ws As Worksheet: Set ws = Sheets("Extract")
Dim rnglook As Range: Set rnglook = ws.Range("Extract")
Dim cusname As Variant
cusname = Application.VLookup(contract.Value, rnglook, 40, False)
If IsError(cusname) Then
MsgBox "Check Contract Number as No Matches found"
contract.SetFocus
Exit Sub
End If
NI = Format(Application.VLookup(contract.Value, rnglook, 35, False), "$ #,##0.00")
interest = Format(Application.VLookup(contract.Value, rnglook, 10, False) / 100, "0.00%#")
branch = Application.VLookup(contract.Value, rnglook, 2, False)
equip = Application.VLookup(contract.Value, rnglook, 46, False)
Very much a novice when it comes to VBA. Thank you in advance.
I have a userform where the user inserts a contract number the clicks on a command button to extract data from a master list. This is all working great, hoever I have tried to handle errors when an unmatch value is entered. The msgbox appears and the user is taken back to the form however when they enter a correct value the "cusname" is not populated.
Any help would be amazing.
Private Sub Userform_Extract()
Dim ws As Worksheet: Set ws = Sheets("Extract")
Dim rnglook As Range: Set rnglook = ws.Range("Extract")
Dim cusname As Variant
cusname = Application.VLookup(contract.Value, rnglook, 40, False)
If IsError(cusname) Then
MsgBox "Check Contract Number as No Matches found"
contract.SetFocus
Exit Sub
End If
NI = Format(Application.VLookup(contract.Value, rnglook, 35, False), "$ #,##0.00")
interest = Format(Application.VLookup(contract.Value, rnglook, 10, False) / 100, "0.00%#")
branch = Application.VLookup(contract.Value, rnglook, 2, False)
equip = Application.VLookup(contract.Value, rnglook, 46, False)