Excel 2016 : Find Numbers That Are Missing From 5000 to 6000 in one column

标签 excel textjoin

我有一列 (A),其中的数字按顺序从 5000 到 6000。现在,有些数字丢失了。例如,下面的列中缺少数字 5004。

  1. 5000
  2. 5001
  3. 5002
  4. 5003
  5. 5005
  6. 5006
  7. ...
  8. 6000

因此,号码5004丢失了。如何找到所有缺失的数字?

最佳答案

如果您想要多个,请将其放在第一个单元格中并复制/向下拖动:

=IFERROR(AGGREGATE(15,6,ROW(INDIRECT("5000:6000"))/(ISERROR(MATCH(ROW(INDIRECT("5000:6000")),A:A,0))),ROW(1:1)),"")

enter image description here

如果您有 Office 365 Excel 并且希望将其放在一个单元格中,请使用以下数组公式:

=TEXTJOIN(",",TRUE,IF(ISERROR(MATCH(ROW(INDIRECT("5000:6000")),A:A,0)),ROW(INDIRECT("5000:6000")),""))

作为数组公式,退出编辑模式时需要使用 Ctrl-Shift-Enter 确认,而不是 Enter。如果操作正确,Excel 会将 {} 放在公式周围。

![enter image description here


如果您没有 Office 365 Excel,但仍希望将其放在一个单元格中,那么您将需要 vba。

将此 UDF 放入附加到工作簿的模块中,并使用上述 TEXTJOIN() 公式。

Function TEXTJOIN(delim As String, skipblank As Boolean, arr)
    Dim d As Long
    Dim c As Long
    Dim arr2()
    Dim t As Long, y As Long
    t = -1
    y = -1
    If TypeName(arr) = "Range" Then
        arr2 = arr.Value
    Else
        arr2 = arr
    End If
    On Error Resume Next
    t = UBound(arr2, 2)
    y = UBound(arr2, 1)
    On Error GoTo 0

    If t >= 0 And y >= 0 Then
        For c = LBound(arr2, 1) To UBound(arr2, 1)
            For d = LBound(arr2, 1) To UBound(arr2, 2)
                If arr2(c, d) <> "" Or Not skipblank Then
                    TEXTJOIN = TEXTJOIN & arr2(c, d) & delim
                End If
            Next d
        Next c
    Else
        For c = LBound(arr2) To UBound(arr2)
            If arr2(c) <> "" Or Not skipblank Then
                TEXTJOIN = TEXTJOIN & arr2(c) & delim
            End If
        Next c
    End If
    TEXTJOIN = Left(TEXTJOIN, Len(TEXTJOIN) - Len(delim))
End Function

关于Excel 2016 : Find Numbers That Are Missing From 5000 to 6000 in one column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42819334/

相关文章:

php - 上传前预览 Excel 或 CSV 数据(可能是 AJAX?)

vba - Excel VBA : Paste problems

arrays - Google Sheets - 根据相应单元格范围中的数值连接单元格范围中的文本的公式

vba - 使用 .DeleteLines 从模块 VBA 中删除特定代码

VBA Excel - .Window 无法识别打开的 Excel 窗口

html - 如何下载文件夹中A列的所有链接?

indexing - 如果单元格中包含另一个表上的值,则 INDEX MATCH 的 TEXTJOIN 唯一值

google-sheets - 将 IMPORTXML Xpath 查询格式化为 Google 表格的可读数据

Excel/Google 表格 - 复制数组并按不同数组的值扩展