Hi everyone,
I'd like to tag along on this great post. I've used a code found in another post in order to create an item selector based on a number of criteria.
Each cell which is filled in is supposed to look in another sheet and return a number of possible options as a result.
My problem is that not all possible results show up in the destination cell, as it seems that the returned value is the 1st one found anf then the search stops. Furthermore, I have the feeling that at some stage the search is not on anymore, as some search fields don't seem to be taken into account (C14:C19)
I've attached the file and would very much appreciate any help I can get in order to understand what I'm doing wrong.
Many thanks,
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C19")) Is Nothing Then
Dim i As Integer
Dim ws As Worksheet
Set ws = Sheets("Source")
Dim match As Integer
match = 0
For i = 1 To 7
If Range("C2").Value = ws.Cells(2, i).Value Or _
Range("C3").Value = ws.Cells(3, i).Value Or _
Range("C4").Value = ws.Cells(4, i).Value Or _
Range("C5").Value = ws.Cells(5, i).Value Or _
Range("C6").Value = ws.Cells(6, i).Value Or _
Range("C7").Value = ws.Cells(7, i).Value Or _
Range("C8").Value = ws.Cells(8, i).Value Or _
Range("C9").Value = ws.Cells(9, i).Value Or _
Range("C10").Value = ws.Cells(10, i).Value Or _
Range("C11").Value = ws.Cells(11, i).Value Or _
Range("C12").Value = ws.Cells(12, i).Value Or _
Range("C14").Value = ws.Cells(14, i).Value Or _
Range("C15").Value = ws.Cells(15, i).Value Or _
Range("C16").Value = ws.Cells(16, i).Value Or _
Range("C17").Value = ws.Cells(17, i).Value Or _
Range("C18").Value = ws.Cells(18, i).Value Or _
Range("C19").Value = ws.Cells(19, i).Value Then
match = 1
With Range("E15")
.Value = ws.Cells(1, i).Value
.Interior.Pattern = xlSolid
.Interior.Color = 65535
.WrapText = True
.Rows.AutoFit
.Font.Bold = True
.Font.Italic = False
End With
Exit For
End If
Next i
If match = 0 Then
With Range("E15")
.Value = "*No matches*"
.Interior.Pattern = xlNone
.Font.Bold = False
.Font.Italic = True
End With
End If
End If
End Sub
Bookmarks