+ Reply to Thread
Results 1 to 5 of 5

Match(Indirect) returns error, added though VBA

  1. #1
    Registered User
    Join Date
    04-29-2015
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    1

    Match(Indirect) returns error, added though VBA

    Hi all,
    I'm trying to add a formula into a cell by VBA

    Sub test()
    Sheets(4).Select
    ActiveWorkbook.Names.Add "tests", RefersTo:="=MATCH(INDIRECT(""B""&ROW()),$A:$A,-1)"
    Cells(1, 3).Formula = "=tests"

    End Sub

    However, it returns the #VALUE error because ROW() returns the value in the form of array (I think) like {1}, then it caused the error to the Indirect function which cannot process input like Indirect("B" & {1}).

    However, if I paste this formula: =MATCH(INDIRECT(""B""&ROW()),$A:$A,-1)
    directly into the cells, it works nicely.
    It also works in VBA if I use only Indirect function

    Anyone has ideas about this problem?

    Thanks
    Last edited by curuaxitin91; 05-27-2015 at 11:22 AM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Match(Indirect) returns error, added though VBA

    I think you are correct in that it is using an array element, but my testing seems to oddly show that it is the indirect() that does it. You can use n() to sometimes get around that issue. This one seems to work:
    =MATCH(N(INDIRECT("B"&ROW())),$A:$A,-1)
    When I put the n() around the row() function, it still returned a value error.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    07-28-2007
    Posts
    35

    Re: Match(Indirect) returns error, added though VBA

    missing the name:= portion
    not sure what you have in [A1]
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-28-2007
    Posts
    35

    Re: Match(Indirect) returns error, added though VBA

    it looks like you're naming a cell reference, not using a formula in a named reference.
    What are you trying to use match indirect for?
    In vba you can use offset to insert or retrieve data without selecting or interacting directly with a cell or range.
    what does the formula accomplish? lets work towards that.

  5. #5
    Registered User
    Join Date
    07-28-2007
    Posts
    35

    Re: Match(Indirect) returns error, added though VBA

    Or just skip the middle man:
    Please Login or Register  to view this content.

+ 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] Vlookup to Pivot Table, using Match function, returns error if can't find match value
    By AndrewHowarth in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-16-2015, 12:10 AM
  2. [SOLVED] Help with vlookup code - returns error if no match
    By cajand in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-30-2014, 06:53 PM
  3. INDIRECT working, but then returns error ?
    By thedreamshaper in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-22-2014, 06:04 PM
  4. Replies: 8
    Last Post: 05-08-2013, 11:47 AM
  5. [SOLVED] MATCH/INDEX Formula Returns an Error Instead of 0
    By livifivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-07-2013, 04:18 PM

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