代码之家  ›  专栏  ›  技术社区  ›  Dom Vito

从Excel中的某个范围创建唯一值列表

  •  0
  • Dom Vito  · 技术社区  · 7 年前

    我将数据(名称)在Excel表格中展开。它位于A列到M列中。

    我想提取范围内每个唯一值的列表(甚至是每个值的列表,然后我可以删除重复项)。

    2 回复  |  直到 7 年前
        1
  •  2
  •   Gary's Student    7 年前

    尝试一下此宏:

    Sub MAINevent()
        Dim it As Range, r As Range, x0
            With CreateObject("scripting.dictionary")
                For Each it In Range("A:M").SpecialCells(2)
                    x0 = .Item(it.Value)
                Next
    
                Set r = Cells(1, "N").Resize(.Count, 1)
                r.Value = Application.Transpose(.Keys)
            End With
    End Sub
    

    enter image description here

        2
  •  1
  •   toroc    7 年前

    你可以用 Go to Special ( G Special )挑选 blanks 并移除它们( Ctrl键 + 选择单元格时)。然后使用描述的公式 here Remove Duplicates .