带有标准的xl2010 / xl2013的TEXTJOIN我有2个工作表。第一个工作表有大约100行,但我们只对Y列感兴趣。列Y中的单元格包含空白单元格(“”),文本和数字以及显示#N / A的单元格。与图片类似,但数据集更大。在第二个工作表中,有一个单元格,我想用“文本和数字”捕获单元格,并在同一单元格中的不同行中显示每个记录(例如,如果有100个单元格中有12个带有'文本和数字',然后我想在第二个工作表的特定单元格中显示此信息。像这样:我尝试过这样的东西,但它似乎只捕获第一行文本(例如标题行):=IFERROR(INDEX('1Comms'!Y:Y,MATCH(TRUE,'1Comms'!Y:Y<>"",0)),"")有没有办法错过这个头衔?我做错了什么,是否有办法做到这一点?
1 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
此TextJoinIfs用户定义函数(也称为UDF)为Excel 2003 - 2013版本提供了基本的TEXTJOIN功能,并通过为简单条件添加可选的错误控制,唯一性,排序和条件参数,为所有版本提供了扩展功能。
此TextJoinIfs UDF代码属于公共模块代码表; 例如Book1 - Module1(代码)。
Option ExplicitPublic Function TextJoinIfs(delim As String, iOptions As Long, iIgnoreHeaderRows As Long, _ rng As Range, ParamArray pairs()) As Variant 'TEXTJOINIFS - Basic TEXTJOIN functionality for XL2003-XL2013 versions ' Expanded TEXTJOINIFS functionality for all versions ' =TextJoinIfs(<delimiter>, <options>, <header_rows>, <string_range>, [criteria_range1, criteria1], [criteria_range2, criteria2], …) ' OPTIONS ' +2 Include blanks ' +4 Include worksheet errrors ' +8 Unique list ' +16 Sort ascending (cannot be used with 17) ' +17 Sort descending (cannot be used with 16) If Not CBool(UBound(pairs) Mod 2) Then TextJoinIfs = CVErr(xlErrValue) Exit Function End If Dim i As Long, j As Long, a As Long, arr As Variant Dim bIncludeBlanks As Boolean, bIncludeErrors As Boolean, bUniqueList As Boolean Dim bSorted As Boolean, bDescending As Boolean bIncludeBlanks = CBool(2 And iOptions) bIncludeErrors = CBool(4 And iOptions) bUniqueList = CBool(8 And iOptions) bSorted = CBool(16 And iOptions) bDescending = CBool(1 And iOptions) Set rng = Intersect(rng, rng.Parent.UsedRange.Offset(iIgnoreHeaderRows - rng.Parent.UsedRange.Rows(1).Row + 1, 0)) With rng ReDim arr(.Cells.Count) If Not IsMissing(pairs) Then For i = LBound(pairs) To UBound(pairs) Step 2 Set pairs(i) = pairs(i).Resize(rng.Rows.Count, rng.Columns.Count).Offset(iIgnoreHeaderRows, 0) Next i End If For j = 1 To .Cells.Count If CBool(Len(.Cells(j).Text)) Or bIncludeBlanks Then If Not IsError(.Cells(j)) Or bIncludeErrors Then If IsError(Application.Match(.Cells(j).Text, arr, 0)) Or Not bUniqueList Then If IsMissing(pairs) Then arr(a) = .Cells(j).Text a = a + 1 Else For i = LBound(pairs) To UBound(pairs) Step 2 If Not CBool(Application.CountIfs(pairs(i).Cells(j), pairs(i + 1))) Then Exit For Next i If i > UBound(pairs) Then arr(a) = .Cells(j).Text a = a + 1 End If End If End If End If End If Next j End With ReDim Preserve arr(a - 1) If bSorted Then Dim tmp As String For i = LBound(arr) To UBound(arr) - 1 For j = i + 1 To UBound(arr) If CBool(LCase(CStr(arr(i))) < LCase(CStr(arr(j))) And bDescending) Xor _ CBool(LCase(CStr(arr(i))) > LCase(CStr(arr(j))) And Not bDescending) Then tmp = arr(j): arr(j) = arr(i): arr(i) = tmp End If Next j Next i End If TextJoinIfs = Join(arr, delim)End Function
=TextJoinIfs(<delimiter>, <options>, <header_rows>, <string_range>, [criteria_range1, criteria1], [criteria_range2, criteria2], …)
简单的TextJoin操作可以丢弃空白和错误,只保留唯一的字符串。与换行符(vbLF)分隔符连接但忽略前两个标题行并按升序排序。
=textjoinifs(CHAR(10), 24, 2, A:A)
扩展TextJoinIfs操作,丢弃空白和错误,仅保留唯一字符串。与分号/空格分隔符连接。范围和标准的一个条件集。
=textjoinifs("; ", 8, 0, B:B, A:A, A2)
扩展TextJoinIfs操作,丢弃空白和错误。与逗号/空格分隔符连接。使用数学比较的多个条件对。
=textjoinifs(", ", 0, 0, B:B, A:A, ">="&D2, A:A, "<="&E2)
非常感谢Lorem Ipsum Generator提供的示例字符串内容。
- 1 回答
- 0 关注
- 284 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消