If cell does not contain specific text, then return a that missing text

Aharris90

New Member
Joined
Jul 13, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am hoping someone can help. I am trying to run a formula that will search a column for text and if that text does not match text within another column to then return the missing text to the bottom of the column the text is missing from.

So lets say Column A has 100 records and Column B has 75 records, I would like row 76 in column B to return the first missing text from Column A.

I hope that makes sense.

Thanks
 
Glad we could help & thanks for the feedback.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
... and just for completeness in case you wanted to run a macro instead of using formulas each time...

VBA Code:
Sub Main()

Dim lastqueryrow, lastcustomerrow As Long
Dim a, b As Long
Dim Found As Boolean

a = 2

lastqueryrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row ' find the last row of data in the datafile
lastcustomerrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row '

Do While a < lastqueryrow + 1  'loop through each customer in Col A
   
    Found = False

    For b = 2 To lastcustomerrow  'compare each with full list inCol B
   
        If ActiveSheet.Range(Cells(b, 2), Cells(b, 2)) = ActiveSheet.Range(Cells(a, 1), Cells(a, 1)).Text Then
            Found = True
            Exit For
        End If
   
    Next b

    If Found = False Then 'store value at bottom of the customer list
        ActiveSheet.Range(Cells(lastcustomerrow + 1, 2), Cells(lastcustomerrow + 1, 2)) = ActiveSheet.Range(Cells(a, 1), Cells(a, 1))
        lastcustomerrow = lastcustomerrow + 1
    End If
   
    a = a + 1
Loop

End Sub
 
Upvote 0
... and just for completeness in case you wanted to run a macro instead of using formulas each time...

VBA Code:
Sub Main()

Dim lastqueryrow, lastcustomerrow As Long
Dim a, b As Long
Dim Found As Boolean

a = 2

lastqueryrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row ' find the last row of data in the datafile
lastcustomerrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row '

Do While a < lastqueryrow + 1  'loop through each customer in Col A
  
    Found = False

    For b = 2 To lastcustomerrow  'compare each with full list inCol B
  
        If ActiveSheet.Range(Cells(b, 2), Cells(b, 2)) = ActiveSheet.Range(Cells(a, 1), Cells(a, 1)).Text Then
            Found = True
            Exit For
        End If
  
    Next b

    If Found = False Then 'store value at bottom of the customer list
        ActiveSheet.Range(Cells(lastcustomerrow + 1, 2), Cells(lastcustomerrow + 1, 2)) = ActiveSheet.Range(Cells(a, 1), Cells(a, 1))
        lastcustomerrow = lastcustomerrow + 1
    End If
  
    a = a + 1
Loop

End Sub
Thank you for your help. Might play around with this to learn as well. thanks again
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top