+ Reply to Thread
Results 1 to 5 of 5

Macro to match values in 2 colums ,write matches

  1. #1
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Macro to match values in 2 colums ,write matches

    Looking for a macro to write all the exact matches in two Columns F and G to H. Example of the data1,2,3,4,5,6,7. Is there a macro code that can do this? , if so can you please assist thanks very much.

    Ricklou

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to match values in 2 colums ,write matches

    Hello ricklou,

    You could do it with a formula,
    =IF(ISERROR(MATCH(F1,G:G,0)),F1,0) - Place in H and copy down.

    Or do you need it to be in VBA?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match values in 2 colums ,write matches

    Quote Originally Posted by Winon View Post
    Hello ricklou,

    You could do it with a formula,
    =IF(ISERROR(MATCH(F1,G:G,0)),F1,0) - Place in H and copy down.

    Or do you need it to be in VBA?
    Thanx Winon

    Gonna try your formulae.........no it dont have to be a macro but even a macro can do a trick...just want all the exact matches from 2 columns in another column. I have 9000 reckords of data. Will test and revert back thanks very much.Nice to see a fellow SAFFER

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to match values in 2 colums ,write matches

    Jy is welkom,

    This formula is even better,

    =IF(ISNA(INDEX(F1,MATCH(G1,F1,0))),"",INDEX(F1,MATCH(G1,F1,0)))

    If your Data starts in Row 5 then change the formula to suit and copy down as far as you need. i.e.

    =IF(ISNA(INDEX(F5,MATCH(G5,F5,0))),"",INDEX(F5,MATCH(G5,F5,0)))

    It is almost allways better to use available formulas, instead of VBA.

    Groete!

  5. #5
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match values in 2 colums ,write matches

    Baie dankie ek toets dit more Winon. Thanks very much. Yes like they say there is always different ways to skin a cat. My data is in F2 G2 running down in the columns.Appreciate your help

    Ricklou

+ 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