troubleshooting Question

Macro to return result name in column B

Avatar of route217
route217Flag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft Excel
4 Comments1 Solution364 ViewsLast Modified:
Hi Experts

the following vba code works 100% but i need to amend the current code so it returns the text name in column b" onwards which match the account number in column A2 onwards...

As opposed to saying MsgBox "You Entered Customer Account Number " & num & " which matches " & Range("B" & r).Value

i want the macro to say account number: XXXXXXX relates to organistion name: BNY etc...



Sub sValidate()
    
    Dim num As String, chK As Long, r As Long, e As Long
    
    num = Application.InputBox(prompt:="Enter: Customer Account Number:", Type:=1)
    
    If num = 0 Then
        MsgBox "Incorrect Customer Account Number!. Please Re-Enter Next Customer Account Number!"
        Exit Sub
    End If
    
    On Error Resume Next
    r = Sheets("Source data").Range("A2:A500000").Find(num, , , xlWhole).Row
    e = Err.Number
    On Error GoTo 0
    
    If e <> 0 Then
        MsgBox "Customer Account Number Not Found!"
        Exit Sub
    End If
    
    MsgBox "You Entered Customer Account Number " & num & " which matches " & Range("B" & r).Value
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Steve
Cost Accountant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2012

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros