Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8278189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:55:29+00:00 2026-06-08T08:55:29+00:00

I have a data table in Excel, that is same as: A B ————-

  • 0

I have a data table in Excel, that is same as:

    A       B
-------------
1. aaa     11
2. bbb     22
3. ccc     #N/A
4. ddd     44

I’ve wrote a VBA function to get value(col B) by key(in col A)
Ex: =getValue(A1)

In this example, if I type =getValue(A3), function is throw #VALUE! error. I was debug and see error at VLOOKUP function. Here is my code:

Public Function getValue(ByVal key As Variant)

    'get value of the cell at column B which has value 'key' at column A on same row
    column2GetValue = 2
    useClosestMatch = False

    'error here if colum2GetValue contain #N/A
    found = Application.WorksheetFunction.VLookup( _
        key, _
        Worksheets(SHEET_CACHE_NAME).Range("A:B"), _
        column2GetValue, _
        useClosestMatch _
    )

    getValue = found
End Function

How to VLOOKUP get #N/A value in VBA?
Thank for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:55:31+00:00Added an answer on June 8, 2026 at 8:55 am

    You can handle the error as below.

    Although I suggest you look consider using a more versatile Find in place of Application.VLOOKUP

    Sub TestMe()
    Dim vTest As Variant
    vTest = Application.VLookup("TesT", Range("A1:B10"), 2, False)
    If IsError(vTest) Then
    MsgBox "Not found", vbCritical
    Else
    MsgBox "value is " & vTest
    End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file that gets external data from database table. I need
I am importing massive amounts of data from Excel that have various table layouts.
I have an Excel table with some data that I would like to export
I have an Excel workbook that utilises a data table (A). I now want
I have following data in excel table r1 r2 r3 r4 r5 v1 v2
im trying to import html table data to an excel file and have succeeded
I have a table in C#, the data is coming from an Excel file.
I have an Excel sheet that I am using to populate data in a
I have data imported from an excel sheet into a table in db. Now
I have a growing set of Excel spreadsheets none with the same data structure.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.