hi group,

In the following vlookup code in macro, if any object is #N/A in the rng
then "*run time error 1004*"occurs.  In such case, i want that it should
show a message as "*lookfor data is not in the range"*

help me how to put msg box if lookfor is not in the rng.

Sub vlookup()
Dim lookfor As Range
Dim rng As Range
Dim col As Integer

Set lookfor = ActiveCell.Offset(0, 2)
    Set rng = Sheets("MV").Columns("A:C")
    col = 3

    dept_code = Application.WorksheetFunction.vlookup(lookfor, rng, col, 0)
End Sub
Thanks & Regards

Rajesh Mahapatra

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts

Reply via email to