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 6945331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:25:21+00:00 2026-05-27T13:25:21+00:00

I have tried hours and hours of examples but I continually get the same

  • 0

I have tried hours and hours of examples but I continually get the same error of #NAME?

I need to use VLOOKUP within a VBA function and then work with the result before putting the result to a cell. Firstly I am having a problem just to get the VBA VLOOKUP part working.

For testing here is the details
Spreadsheet is…

Worksheet = Sheet1

4 rows x 2 columns of data.
Cells D1:E4
Dance : 23
French : 42
English : 2
Music : 33

In cell A1 I will have a user imputed content that will a value from column D eg French

In Cell B1 I will call the function
=GetQty(A1,D1:E4,2)
but I always get #NAME?

1) How do I call the function properly. Am I doing this corretly?

In my VBA function “GetQty” I just want to do the VLOOKUP on a value of cell A1 and return the value from the matching entry from the table(Cell D1:E4), eg return 42 and then place that value into column B1 and (also column C1 via the VBA and not just using a formula in the worksheet cell of =B1 )

Here is one of the many examples I have tried in my function just to get the VLOOKUP to work.

Function GetQty(Celly As Range, CellyRange As Range, Colretval As Integer) As Integer
Dim result As String
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Sheet1")
GetQty = Application.WorksheetFunction.VLookup(sheet.Range(CellyRange), sheet.Range(CellyTable), Colretval, False)
End Function

I have tried many examples but I always get #NAME? error

  • 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-05-27T13:25:22+00:00Added an answer on May 27, 2026 at 1:25 pm

    There are a few issues, mainly:

    • First argument for Vlookup cannot be a range, needs to be a value
    • It’s safer to not declare the return type as Integer

    Here’s a working example of how to use Vlookup from VBA, maybe it’ll help (you call it just VLookup):

    Function VBAVlookup(ByVal search As Variant, _
                        cell_range As Range, _
                        offset As Long, _
                        Optional opt As Boolean = False)
    
    Dim result As Variant
    result = WorksheetFunction.VLookup(search, cell_range, offset, opt)
    'do some cool things to result
    
    VBAVlookup = result
    
    End Function
    

    Unless what you are doing is rather sophisticated, you can always use =Vlookup(...) * 55 +2 and stuff like that to return a manipulated result from vlookup using just one formula.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried different examples to filter a gridview by dropdownlist, but is it
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have tried to integrate the Picasa API on iPhone, compiles fine, but I
I have tried to find how to create DLL-s on linux using google, but
I have tried to use ASP.NET MVC for a while, then I face a
I have tried to use some of the widgets in JQuery UI on an
Jump to the EDIT for a better explanation! I have tried to get this
I have tried going through all the examples in core plot, esp dateplot example,
I've tried all the time calculating examples I found on this site but somehow
I have tried <ul id=contact_list> <li id=phone>Local 604-555-5555</li> <li id=i18l_phone>Toll-Free 1-800-555-5555</li> </ul> with #contact_list

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.