是否存在从vlookup返回多个值的问题?我希望工作表1中的col将多个值返回给一个单元格,或者是否有其他方法来显示这个值(宁愿不要枢轴)?
Sheet 1:具有所有唯一值(Col,以及Col中的返回值),
Sheet 3:Col有重复的字符串值,它们对应于Col中唯一的字符串,包括空格。
编辑
表1或期望结果:

表1:当前

片3电流

电流公式
=VLOOKUP(F2,Sheet3!A:B,2,FALSE) 返回的大部分是0,因为空白或对应于唯一值的多个值。
发布于 2016-08-09 09:25:29
那么,就VBA而言,您必须从我发送给您的链接中稍微修改代码。这应该是可行的:
Option Explicit
Function vlookupmulti(rngLookup As Variant, rngSource As Range, col As Double) As String
Dim d As Double, strCell As String
'Error if range has less columns than col
If rngSource.Columns.Count < col Then
vlookupmulti = CVErr(xlErrNA)
Exit Function
End If
'Loop through rows in the lookup column
For d = rngSource.Row To rngSource.Rows.Count
If rngLookup = Sheets(rngSource.Parent.Name).Cells(d, rngSource.Column).Value Then
strCell = Sheets(rngSource.Parent.Name).Cells(d, rngSource.Column + col - 1).Value
If Len(strCell) > 0 Then vlookupmulti = vlookupmulti & strCell & ", "
End If
Next d
'Remove comma at end
If Right(vlookupmulti, 2) = ", " Then
vlookupmulti = Left(vlookupmulti, Len(vlookupmulti) - 2)
End If
'Give error if no results
If vlookupmulti = "" Then
vlookupmulti = CVErr(xlErrNA)
End If
End Functionhttps://stackoverflow.com/questions/38832559
复制相似问题