Hello,
I am trying to type the below formula to a cell :
The formula returns the row index separated by commas of all the occurrences found.
The searched values are in column B of the below screenshot ("HTS Codes for PNs wo HTS.xlsx") while the second screenshot ("HTS Codes for PNs wo HTS.xlsx") shows the range in which the values should be searched.
"HTS Codes for PNs wo HTS.xlsx" "HTS Codes for PNs wo HTS.xlsx"
I am getting a Type missmatch error. I cannot figure what is causing the error. I would appreciate some guidance towards the solution.
Thanks
I am trying to type the below formula to a cell :
VBA Code:
"=TEXTJOIN("","",TRUE,IF(ISNUMBER(" _
& "SEARCH(B" & i & "," & descRng & ")),ROW(" & descRng & _
"),""""))"
The searched values are in column B of the below screenshot ("HTS Codes for PNs wo HTS.xlsx") while the second screenshot ("HTS Codes for PNs wo HTS.xlsx") shows the range in which the values should be searched.
"HTS Codes for PNs wo HTS.xlsx" "HTS Codes for PNs wo HTS.xlsx"
I am getting a Type missmatch error. I cannot figure what is causing the error. I would appreciate some guidance towards the solution.
Thanks
VBA Code:
Sub test ()
Dim bomWb As Workbook, htsWb As Workbook
Dim bomWs As Worksheet, htsWs As Worksheet
Dim bLrow As Long, hLrow As Long
'lrow and i are private variables declared within the same module
Dim descRng As Range
Set bomWb = Workbooks("BOM_1926_GM_09.11.24.xlsx")
Set bomWs = bomWb.Worksheets(1)
Set htsWb = Workbooks("HTS Codes for PNs wo HTS.xlsx")
Set htsWs = htsWb.Worksheets(1)
bLrow = 755
hLrow = 103
Set descRng = bomWs.Range(Cells(2, 6), Cells(bLrow, 6))
With htsWs
For i = 2 To hLrow
.Cells(i, 5).Formula = "=TEXTJOIN("","",TRUE,IF(ISNUMBER(" _
& "SEARCH(B" & i & "," & descRng & ")),ROW(" & descRng & _
"),""""))"
Next i
End With
End Sub