Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88886

Looping and scanning a list of e.g., 200 strings against a column with string data (Excel, VBA, Macros)

$
0
0

To the best of my efforts (VBA novice) I have been trying to write using stack and other resources a macro which would allow me to scan a given list of strings in excel against another much larger list for possible partial matches (Vlookup seems not to do a trick and Instr is a lot better for this it seems). I have been able to get some code working which leverages a loop to scan through a specific range and look for a single string of interest. For example let's say I have 20 cells in Column C with various names of fruits and vegetables and I would like to highlight only specifc ones of interest for me. In the code's case below I have included a string "Cher" (for Cherry) to be searched for against the range which if found creates a hit to the right of the column searched.

My major question would be how to adjust the code so that I could not only search for a single string like "Cherry", but how to run it against a very long list e.g. of 200 items when dealing with a couple of thousands of rows of data?

Sub listchecker()

    Dim cell As Range
        For Each cell In Range("C2:C20")
            If InStr(cell.Value, "Cher") > 0 Then
                cell.Offset(0, 1).Value = cell.Value
            End If
        Next cell

    End Sub

Thank you in advance for anyone's help!


Viewing all articles
Browse latest Browse all 88886

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>