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