Compare two columns in EXCEL and if they are equal return a certain value

1

I'm having trouble generating a logical structure (If) to validate some data. It's for a search. follows the explanation:

  • There are two columns ( B and H ). In the B column there are all Brazilian municipalities and in column H there are not all (but most).

  • TheIcolumncontainsthegradesobtainedbythemunicipalitiesintheHcolumn

  • TheCcolumnshouldreceiveallthedataintheIcolumnintheirrespectivemunicipalities
  • AsintheBcolumntherearemorecountiesthanintheHcolumn(aspreviouslyquoted)IamtryingtocreateaVBArulethatcomparestheBcolumnwithH,ifthemunicipalitiescomparedarethesame,theIcolumndatawillbepassedtotheCcolumninyourmunicipality
  • Ex:ComparesB2withH2,iftheyareequal,C2receivesI2.
  • ItriedtodoinVBAbutasIcouldnotgetanywherenearthegoal,Idonotconsideritnecessarytopostthecode(whichismessyandnotcommented).IfanyoneknowsawaytodoitwithoutbeingVBA,withoutproblems,theimportantthingformeistheresult.

  • Photooftheexpectationofhowtostay:

OBS: The red townships in the B column are those that are not H

The D and E columns can be disregarded, and I understand how I can do one for them.

    
asked by anonymous 04.09.2017 / 01:39

1 answer

0

In this case you do not need to do it in VBA, you can use PROCV as follows:

In cell C2 :

=PROCV($A2;$H$2:$I$6000;2;FALSO)

In the example above I put it as having around 6,000 counties, but see how many rows it has in your spreadsheet.

In addition, you could use the following formula to show n/a as quoted in your question:

=SE(ÉERROS(PROCV($A2;$H$2:$I$6000;2;FALSO));"n/a";PROCV($A2;$H$2:$I$6000;2;FALSO))

I hope I have helped!

    
04.09.2017 / 02:21