要输入公式的Sheet表里依次按 Alt F11 I M 这4个键
这样出来一个对话框,在那里把下边的内容复制粘贴到该对话框里
Function HB(if_range, Optional criteria, Optional hb_range, Optional separator)
If IsMissing(separator) Then separator = " "
If IsMissing(hb_range) Then Set hb_range = if_range
If IsMissing(criteria) Then
For Each c In hb_range.Cells
t = t & separator & c
Next
Else
If Left(criteria, 1) = "F" Then
For i = 1 To if_range.Cells.Count
If InStr(if_range.Cells(i), Mid(criteria, 2)) Then t = t & separator & hb_range.Cells(i)
Next i
Else
For i = 1 To if_range.Cells.Count
If Application.Evaluate(if_range.Cells(i) & criteria) Then t = t & separator & hb_range.Cells(i)
Next i
End If
End If
HB = Mid(t, 2)
End Function
之后退出该对话框
输入 =HB(H$6:H$47,"F"&D2,J$6:J$47,CHAR(10))
如:
=a1&b1&c1