So I have two columns Material, and Process. The user selects a material and i need a function to look in a different sheet for all process matches to that material. Example would be a user picks Steel, and the the value returned is an array containing all processes that have the material steel. This shouldn't be too hard for someone better than I am at VBA coding, but I'm lost. Below is what ive tried and it just returns "0"
Function dependentSearch(Phrase As String) As Variant
Dim returnArray As Variant
Dim I As Long
Sheet6.Activate
' Get last row count
Dim last_row As Long
last_row = Cells(Rows.Count, "O").End(xlUp).Row
' Loop through rows in sheet6
For I = 1 To last_row
' Check if material matches and if so store value from the adjacent cell
If Phrase = Range("C" & I).Text Then
returnArray = returnArray + Range("D" & I)
End If
Next I
dependentSearch = returnArray
End Function
Bookmarks