Hi All;
I am trying to return values from an array based on a search term. The array is being captured correctly but I can't search the array return correctly. When I hardcode the array, the search does work.
I get a type mismatch 13 when I run the code.
Worksheet = "data"
dynamic table = "data"
Column A has dynamic array
Column A header = ""#MODEL_NUMBER""
search term = "RP"
Values in Column A
----------
#MODEL_NUMBER
RP060324-1
A
B
C
I
B
T
RP060324-1
RP060324-1
------------
What am I doing wrong?
Thanks,
Mike
I am trying to return values from an array based on a search term. The array is being captured correctly but I can't search the array return correctly. When I hardcode the array, the search does work.
I get a type mismatch 13 when I run the code.
Worksheet = "data"
dynamic table = "data"
Column A has dynamic array
Column A header = ""#MODEL_NUMBER""
search term = "RP"
Values in Column A
----------
#MODEL_NUMBER
RP060324-1
A
B
C
I
B
T
RP060324-1
RP060324-1
------------
Code:
Sub data_table_replacement_part_search()
Dim replacement_part_array As Variant
model_number_row_count = ThisWorkbook.Sheets("data").Range("data").ListObject.ListRows.Count
model_number_index = ThisWorkbook.Sheets("data").ListObjects("data").ListColumns("#MODEL_NUMBER").Index
replacement_part_array = ThisWorkbook.Worksheets("data").Range(Cells(2, model_number_index), Cells(model_number_row_count, model_number_index))
'replacement_part_array = Array("RP1", "RP2", "BOB")
'replacement_part_array = Array(replacement_part_array_results)
search_term = "RP"
filter_term = Filter(replacement_part_array, search_term)
For Each x In filter_term
MsgBox x
Next
End Sub
What am I doing wrong?
Thanks,
Mike