+ Reply to Thread
Results 1 to 17 of 17

How to Return Row Number From Match Function

  1. #1
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    How to Return Row Number From Match Function

    Hi everyone. I am trying to create a message box to show the row number from a match function. For example, the word "revenue" in Sheet1 is also in Sheet2. I would like to return the row number in Sheet2 for the word "Revenue." Attached is an example of what I am working with and what I'd like returned. Any help is highly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: How to Return Row Number From Match Function

    Not sure what Keebellah has suggested, but how about
    =MATCH(A2,Sheet2!A1:A3,0)

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to Return Row Number From Match Function

    If you are looking for a VBA solution, you have two options to find the row number of the string being searched on another sheet i.e. Match and Find.

    You may try one of these codes to get the desired output.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How to Return Row Number From Match Function

    sktneer, maybe I should've specified my end goal because I'm definitely mis-communicating. In the end, when I click on cell A2, I'd like the message box to appear showing the value in the selected cell's row number in Sheet2. I super appreciate this though. Any help is highly appreciated. This has been causing me hours of confusion lol.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Return Row Number From Match Function

    Keebellah & EdwardSnowden. That's enough. No more side swipes, please.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How to Return Row Number From Match Function

    My apologies Glenn.

    Still, any feedback is welcomed. This has been quite hard and I'm not stopping until I figure it out and this forum has been a non-stop source of information for me.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Return Row Number From Match Function

    Apologies not required... from anyone. It's late evening in India now. Hopefully sktneer will be back in the Indian morning. I hope he or AN Other it gets sorted for you.

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: How to Return Row Number From Match Function

    How about
    Please Login or Register  to view this content.
    This needs to go in the Sheet1 module

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: How to Return Row Number From Match Function

    It's the same (in the attached file )
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  10. #10
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to Return Row Number From Match Function

    Sorry, I was away from the system.

    Quote Originally Posted by EdwardSnowden View Post
    sktneer, maybe I should've specified my end goal because I'm definitely mis-communicating. In the end, when I click on cell A2, I'd like the message box to appear showing the value in the selected cell's row number in Sheet2. I super appreciate this though. Any help is highly appreciated. This has been causing me hours of confusion lol.
    There is an Event called Worksheet_SelectionChange which gets triggered automatically when the selection on the sheet gets changed.

    e.g. if you select any cell in column A (of course the range can be specified which should trigger this event), the SelectionChange event will be triggered and it can perform some predefined actions but the SelectionChange event would be triggered each time you select a cell in the specified range which maybe a downside to this approach.

    Instead, a Worksheet_BeforeDoubleClick event which will be triggered when you double click in a cell would be more practical for you.

    Please have a look at the code proposed in Post#8 and see if that approach works for you, otherwise it can be easily changed to the SelectionChange event as you requested.

    Also, find the attached with the code placed on the Sheet1 Module. To view the code, right click on Sheet1 Tab and choose View Code.
    To test the code, double click in the cell A2 and a MsgBox will be popped up with the desired output.

    Right now the BeforeDoubleClick event code in the attached will be triggered when you double click in any cell in Column A but if you want to have this functionality for the cell A2 only, the code can be easily tweaked to do so.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How to Return Row Number From Match Function

    sktneer

    This is exactly what I needed. Thank you for not only providing a solution, but giving a detailed explanation that will enable me to do this on my own in the future.

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to Return Row Number From Match Function

    You're welcome Edward! Glad your issue is resolved and you found the explanation helpful.
    Thanks for the feedback and rep.

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: How to Return Row Number From Match Function

    Quote Originally Posted by EdwardSnowden View Post
    Still, any feedback is welcomed.
    My sentiments exactly.
    Except that unfortunately you decided to totally ignore me

  14. #14
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to Return Row Number From Match Function

    @Edward

    I think you forgot that the solution in the file I uploaded was originally provided by Fluff in his post#8 so please acknowledge the contribution of Fluff in resolving your issue and you should thank him for the time he devoted to your question. 👍

  15. #15
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How to Return Row Number From Match Function

    Fluff, my apologies. After your comment there had been a debate between a moderator and I over an individual's comments, which led to my comments and his/her comments being deleted, and I was completely side tracked. I did not mean to ignore your well thought out response and have added to your reputation as is deserved. My apologies again.

  16. #16
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: How to Return Row Number From Match Function

    Apology accepted & many thanks for the reply & the rep

  17. #17
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How to Return Row Number From Match Function

    You are more than welcome. I look forward to learning more from you in the future!

+ 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. how to use match function to match that number and return a value?
    By eddie01001 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-05-2019, 03:55 PM
  2. Match function won't return correct row number
    By Shaffness in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-23-2016, 03:28 PM
  3. Query date range and ref number match to return another reference number
    By 27paul0 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2015, 07:31 AM
  4. [SOLVED] Function to match text and return number in adjacent cell?
    By danoswalt in forum Excel General
    Replies: 6
    Last Post: 12-16-2014, 01:47 PM
  5. Match function to return column number for matching date errors
    By martinez77 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2014, 10:39 AM
  6. INSERT/MATCH Function - can I match and return more than a single result?
    By nickwee in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2014, 06:02 AM
  7. Replies: 5
    Last Post: 02-13-2014, 05:37 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