简体   繁体   English

如何从两列Excel VBA中提取唯一值

[英]How to extract unique values from two columns Excel VBA

我需要获取列(A)和列(C)之间的唯一值才能在列(E)中显示

This code: 这段代码:

Sub GetUniques()
    Dim Na As Long, Nc As Long, Ne As Long
    Dim i As Long
    Na = Cells(Rows.Count, "A").End(xlUp).Row
    Nc = Cells(Rows.Count, "C").End(xlUp).Row
    Ne = 1

    For i = 1 To Na
        Cells(Ne, "E").Value = Cells(i, "A").Value
        Ne = Ne + 1
    Next i
    For i = 1 To Na
        Cells(Ne, "E").Value = Cells(i, "C").Value
        Ne = Ne + 1
    Next i

    Range("E:E").RemoveDuplicates Columns:=1, Header:=xlNo
End Sub

will produce this type of result: 将产生这种类型的结果:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 比较两个不同列的值与excel VBA中的唯一条件 - comparing values of two different columns with a unique condition in excel VBA excel,根据两列之间的关系从一列中提取唯一值 - excel, extract unique values from one column based on the relationship between two columns EXCEL VBA-从单元格提取数字并将其粘贴到两个不同的列中? - EXCEL vba - extract numbers from cell and paste into two different columns? 如何根据其他两列的条件从一列中提取唯一值,使用 or 语句? - How to extract unique values from one column based on criteria from two other columns, with or statement? 比较两列Excel VBA中的唯一字符串 - Comparing unique strings in two columns Excel VBA 唯一值两列 combobox vba - Unique values two columns combobox vba 如何从Excel VBA的值范围返回唯一值 - How to return unique value from a range of values Excel VBA Excel - 如何在不使用数组公式和辅助列的情况下将唯一值从一列提取到另一列? - Excel - How can I extract unique values from one column to an another column without using array formulas and helper columns? 从 D 列中提取唯一值并组合在一个单元格中。 Excel VBA - Extract unique values from Column D and combine in a single cell. Excel VBA 从两列中提取唯一的不同列表 - Extract unique distinct list from two columns
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM