帶有標(biāo)準(zhǔn)的xl2010 / xl2013的TEXTJOIN我有2個(gè)工作表。第一個(gè)工作表有大約100行,但我們只對(duì)Y列感興趣。列Y中的單元格包含空白單元格(“”),文本和數(shù)字以及顯示#N / A的單元格。與圖片類似,但數(shù)據(jù)集更大。在第二個(gè)工作表中,有一個(gè)單元格,我想用“文本和數(shù)字”捕獲單元格,并在同一單元格中的不同行中顯示每個(gè)記錄(例如,如果有100個(gè)單元格中有12個(gè)帶有'文本和數(shù)字',然后我想在第二個(gè)工作表的特定單元格中顯示此信息。像這樣:我嘗試過這樣的東西,但它似乎只捕獲第一行文本(例如標(biāo)題行):=IFERROR(INDEX('1Comms'!Y:Y,MATCH(TRUE,'1Comms'!Y:Y<>"",0)),"")有沒有辦法錯(cuò)過這個(gè)頭銜?我做錯(cuò)了什么,是否有辦法做到這一點(diǎn)?
1 回答

慕容3067478
TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊
此TextJoinIfs用戶定義函數(shù)(也稱為UDF)為Excel 2003 - 2013版本提供了基本的TEXTJOIN功能,并通過為簡(jiǎn)單條件添加可選的錯(cuò)誤控制,唯一性,排序和條件參數(shù),為所有版本提供了擴(kuò)展功能。
此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], …)
簡(jiǎn)單的TextJoin操作可以丟棄空白和錯(cuò)誤,只保留唯一的字符串。與換行符(vbLF)分隔符連接但忽略前兩個(gè)標(biāo)題行并按升序排序。
=textjoinifs(CHAR(10), 24, 2, A:A)
擴(kuò)展TextJoinIfs操作,丟棄空白和錯(cuò)誤,僅保留唯一字符串。與分號(hào)/空格分隔符連接。范圍和標(biāo)準(zhǔn)的一個(gè)條件集。
=textjoinifs("; ", 8, 0, B:B, A:A, A2)
擴(kuò)展TextJoinIfs操作,丟棄空白和錯(cuò)誤。與逗號(hào)/空格分隔符連接。使用數(shù)學(xué)比較的多個(gè)條件對(duì)。
=textjoinifs(", ", 0, 0, B:B, A:A, ">="&D2, A:A, "<="&E2)
非常感謝Lorem Ipsum Generator提供的示例字符串內(nèi)容。
添加回答
舉報(bào)
0/150
提交
取消