• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to show message box with vlookup content

its perfect but i want to vlookup a and bring 3d value
i put Range("D7:F8"), 3, False) in macro but does not work
Hi,

You can't simply alter the VLOOKUP range in the code you need to also change the range for the event code like below.

Note in the code below the event code executes when you click in F19:F1000

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Dim MyVal As String, r
If Not Intersect(Target, Range("F19:F1000")) Is Nothing Then
MyVal = WorksheetFunction.VLookup(Target.Value, Range("D7:F8"), 3, False)
On Error GoTo 0
If MyVal <> "" Then
r = MsgBox("Found value is :- " & MyVal, vbOKOnly, "Lookup")
End If
End If
End Sub
 
can i concacenate the target value inside VLookup(Target.Value, Range("D7:F8"), 3,

with something like range Range("E19:E1000") for example??
 
can i concacenate the target value inside VLookup(Target.Value, Range("D7:F8"), 3,

with something like range Range("E19:E1000") for example??
Hi,

I'm afraid I've lost track of what you're trying to achieve. If you have duplicate values in the first column of the table array then VLOOKUP will return the first instance, that's how it works. There are methods of finding the nth match.

If you can define your requirement; preferably by uploading a workbook with the requirement explained, then someone will help you out.
 
Back
Top