Search range of cells on 1 page for keywords found on page 2

dwg83

Board Regular
Joined
Nov 8, 2006
Messages
174
I have been pulling my hair out on this one! I am searching a column of data for keywords found on a separate sheet and indicating if that cell has a keyword. I am trying to store the keywords in an array, but for some reason it is not working. When I had the keywords on the same sheet and stored in an array, this code worked. What am I missing? Thanks!!!

Code:
Private Sub CommandButton1_Click()
    Dim Lastrn
    Dim LR As Long, i As Long, j As Long
    Dim mealsout() As Variant
    Dim Categories As Worksheet
    Set Categories = Worksheets("Categories")

    Categories.Activate

    Lastrn = Categories.Range("B65536").End(xlUp).Row
    ReDim mealsout(1 To Lastrn - 1, 1 To 1)
    mealsout = Range(Cells(2, 2), Cells(Lastrn, 2)).Value
    Cells(1, 1) = "OK"
       
    Worksheets("Import").Activate
      
    LR = Range("C" & Rows.Count).End(xlUp).Row
    
    For i = 2 To LR
        With Range("C" & i)
            For j = LBound(mealsout) To UBound(mealsout)
                If .Value Like "*" & mealsout(j, 1) & "*" Then
                    .Offset(, 3).Value = True
                    Exit For
                End If
            Next j
        End With
        Cells(i, 7) = i
    Next i


End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

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