



















Create a custom function using VBA to handle it.
1. Open the Excel file, press "Alt F11" to open the VBA editor window, then click the right mouse button on the blank area on the left, select "Insert," and then "Module."

2. Paste the following code in the blank area on the right:
Function HeBing(rng1 As Range, s As String, rng2 As Range, f As String) As String
Dim Arr1, Arr2
Dim r As Long
r = rng1.End(xlDown).Row - rng1.Row + 1
Arr1 = rng1.Resize(r, 1): Arr2 = rng2.Resize(r, 1)
Dim i As Long
For i = 1 To UBound(Arr1)
If Arr1(i, 1) = s Then
If HeBing = "" Then HeBing = Arr2(i, 1) Else HeBing = HeBing & f & Arr2(i, 1)
End If
Next
End Function
3. Usage:
=HEBING(Where to search, What to search for, What data to return, What to separate with in the cell)
eg: =hebing(A:A,C1,B:B,",")
This content is automatically aggregated by InertiaRSS (RSS Reader) for reading reference only. Original from — Copyright belongs to the original author.