How to search for values in column A that do not exist in column B?

Asked

Viewed 33,862 times

4

For example, I have a spreadsheet:

  [   A   ] [   B   ]
1  valor1     valor1
2  valor2     valor2
3  valor3     valor3
4  valor4     valor4
5  valor5     valor6

You can see that in column B, there is no valor5, what I wanted is to find the values that have in column A but are not in B. I have already searched formulas, etc, but I can not do it. Would anyone have any idea how to do that?

4 answers

2

There are several ways to do what you asked, one of them would be to highlight the cell for a quick view. My suggestion is to use conditional formatting as follows:

  1. Select column "A" and click and Conditional Formatting > New Rule:

inserir a descrição da imagem aqui

  1. Select option 1 (from the image), insert the formula below in 2 and format the cell in 3 as desired:

inserir a descrição da imagem aqui

Below is the Formula:

=SE(E($A1<>"";ÉERROS(PROCV($A1;B:B;1;FALSO)));VERDADEIRO;FALSO)

This is one of the ways to do, but as in everything in Excel, there are always several ways to solve the same problem, it is up to the taste of each.

Here is an answer with something similar for reference:

Checking and Filling Excel Cells

2


The function you seek is the PROCV

With the formula I put below, you are scanning the range $A$1:$A$5 in search of the content that will be in the cell marked in the first parameter (which in this case is the B1). If you do not find the value, it will return "nay".

Place this formula in the result column and drag it down to auto complete on the lines below.

=SE.ERRO(PROCV(B1;$A$1:$A$5;1;0);"não")

The result should be:

  [   A   ] [   B   ] [ RESULTADO ]
1  valor1     valor1    =SEERRO(PROCV(B1;$A$1:$A$5;1;0);"não")
2  valor2     valor2     valor2
3  valor2     valor3     não
4  valor4     valor4     valor4
5  valor5     valor6     não

If you need more details, access the documentation that very well explained

  • Mine is returning #NAME? in column C. Can you tell me why? I say column C which is the column I am applying the formula.

  • That. "C" column equals the "result" column of the above example. Make sure it is not the cell formatting. If not, you may be putting the reference where it is not allowed. Be sure to copy the same formula value: =SE.ERRO(PROCV(B1;$A$1:$A$5;1;0);"não") @Lucascarvalho

  • Ta dar that the formula contains unrecognized text.

  • Then let’s compare our files. I uploaded my worksheet with the functional code at https://drive.google.com/open?id=0B9We4Z4fXcLcY0pCNjNRFNwV3M address. Check what may be happening and return to us @Lucascarvalho . Just one more tip, after it works out, select the results column and put it to sort from A to Z, and choose to expand the selection. Ready. Now you will have the values uncontained separate from others. Much easier to work with them afterwards.

  • @Lucascarvalho if the question has been answered and solved, select the answer that cleared your question.

  • 1

    It’s not SE.ERROR in the case, but SEERRO. It worked out, but, it only checks if the item in column A was above the item in column B, if not it goes like "no"

Show 2 more comments

0

The countif function can also be used, but as I know perform only in VBA, follows the code. That can be converted to Excel Function or be created as UDF.

Dim ws As Worksheet

Set ws = ThisWorkbook.Sheets(1)
rLastA = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
rLastB = ws.Cells(ws.Rows.Count, 2).End(xlUp).Row

For i = 1 To rLastA

    Set c = ws.Cells(i, 1)
    Set rng = ws.Range(ws.Cells(1, 2), ws.Cells(rLastB, 2))

    x = Application.WorksheetFunction.CountIf(rng, c)

    If x < 1 Then Valores = Valores & vbNewLine & c
Next i
MsgBox Valores

Can be performed with functions by the logic of

Count IF the value of a cell of column A is equal to that of all of column B; and then if the value of the counter is 0(no Match), then returns the value name of the cell of column A if there is no match

Other ways to perform with VBA is by using .Find, Loop com condicional, Loop de Autofiltro and Scripting.Dictionary, and if the spreadsheet is too large the last two are more efficient.

-2

Try it like this:

Code Snippet

Sub excluirvalores()
x = 1
'O loop While corre de celula em celula até a ultima celula preenchida
While Cells(x, 1).Value <> ""
y = x + 1
While Cells(y, 1).Value <> ""
'Verifica se o valor é o mesmo
If Cells(y, 1).Value = Cells(x, 1).Value Then
'exclui a celula se o valor for o mesmo
Cells(y, 1).Delete Shift:=xlUp
End If
y = y + 1
Wend
x = x + 1
Wend
End Sub

Note: The instruction Cells(x,1) refers to cell A1 if the value of x is 1, if the value of x is 2 it refers to cell A2.

   Para Fazer Referencia à celula B1 mude a Instrução de Cells(x,1) para Cells(x,2) e assim por diante.

I hope it helps

Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.