+ Reply to Thread
Results 1 to 5 of 5

Trying to use the application object with the match function, getting error 2015

  1. #1
    Registered User
    Join Date
    10-08-2014
    Location
    Blacksburg, Virginia
    MS-Off Ver
    2013
    Posts
    18

    Trying to use the application object with the match function, getting error 2015

    Sub naming()
    Range("A2", Range("A2").End(xlDown)).name = "Names"
    End Sub
    Sub MatchApplication()
    Dim val As Variant, name As String

    name = InputBox("Enter the name you wish to search for")

    val = Application.Match(name, "Names", 0)


    End Sub

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trying to use the application object with the match function, getting error 2015

    Try
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    10-08-2014
    Location
    Blacksburg, Virginia
    MS-Off Ver
    2013
    Posts
    18

    Re: Trying to use the application object with the match function, getting error 2015

    That worked! Thank you! I am trying to use that match function value in an offset function to give me the values of the cells corresponding to a user entered name, however I am now getting an object defined error and am not quite sure why... Any thoughts?

    Sub naming()
    Range("A2", Range("A2").End(xlDown)).name = "Names"
    End Sub

    Sub MatchApplication()
    Dim val As Variant, name As String, x As Variant

    name = InputBox("Enter the name you wish to search for")

    val = Application.Match(name, Range("Names"), 0)
    If IsError(val) Then MsgBox "not found"

    val.Offset(0, 1).value = x

    MsgBox x

    End Sub

  4. #4
    Registered User
    Join Date
    10-08-2014
    Location
    Blacksburg, Virginia
    MS-Off Ver
    2013
    Posts
    18

    Re: Trying to use the application object with the match function, getting error 2015

    I realize that val is equal to the location of a cell and is not the actual 'reference cell' that offset requires but I am not sure how to make the two relate together

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trying to use the application object with the match function, getting error 2015

    The range that you have named "Name" is in a column.

    val is the number of rows (relative to the Name) on which the entered name is found.

    Range("Names").Cells(val, 1) is the cell that contains the entered name.

    Range("Names").Cells(val, 2) is one cell to the right of that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  2. Workaround for Error 2015 when function too long using Application.Evaluate?
    By jprealini in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2014, 04:06 PM
  3. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  4. Object Required error on Application.Match function.
    By ctckark1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-12-2011, 11:01 AM
  5. [SOLVED] Error 2015 with Application.Evaluate
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2006, 11:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1