+ Reply to Thread
Results 1 to 7 of 7

Trouble Converting Match Formula to VBA

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Trouble Converting Match Formula to VBA

    I am having the hardest time converting the following cell formula to use it in VBA. No matter what i try or which way i write it, i keep getting the "Unable to get the Match property of the WorksheetFunction class" error.

    =MATCH("Plan Week:"&H19,MasterSheet!80:80,0)


    This is my latest attempt that failed:

    Please Login or Register  to view this content.
    Last edited by PY_; 01-10-2013 at 09:16 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,957

    Re: Trouble Converting Match Formula to VBA

    What does the original worksheet formula return?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,463

    Re: Trouble Converting Match Formula to VBA

    Well, you have DIMmed a variable called ColumnNumber and used that in the message box, but the MATCH function assigns its value to a variable called RowNumber.

    Hope this helps.

    Pete

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,957

    Re: Trouble Converting Match Formula to VBA

    Sounds like it's failing before it gets to the msgbox.

    You're answering the questions in the wrong order


    Regards, TMS

  5. #5
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Trouble Converting Match Formula to VBA

    The original formula returns 15 in the cell. I have made a sample spreadsheet that is basically what my real sheet has in it.


    I thought i edited that RowNumber issue but i guess it didnt save on here. Its been corrected now, thanks
    Attached Files Attached Files

  6. #6
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Trouble Converting Match Formula to VBA

    Well crud!

    Now its working... this is the code that works in my sample file:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,957

    Re: Trouble Converting Match Formula to VBA

    Well, one or two differences there. Maybe it didn't like RowNumber being a variant. Maybe it wasn't finding what it was looking for.

    Incidentally, you don't need brackets in the msgbox.

    Regards, TMS


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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