获取combox选中的值_「技巧1001-11」-Excel删除重复值,我用了7种方法

今天我们继续分享一下技巧1001-11,重复值话题很多小伙伴可能还在为删除重复值烦恼,但是你知道吗?小编下午,随手整理了一下,居然就有7种方法之多下面我们就来一一解析一下看完,我们就可以终结这个话题了!!

方法1:自带去重法

该功能从Excel2007新增的功能,2003及以下版本无法使用请使用下方其他方法

使用方法:选中数据列,选择数据-删除重复值,确定即可如果多列,需要勾选,判断重复的列

ce459d8b2928c47cde40173cb359fb90.gif

方法2:高级筛选法

我们利用自带的高级筛选功能处理,只需要勾选选择不重复的记录即可

d671654f53d4c5e4fe776c6977d1e042.gif

方法3:透视表法

利用透视表,行字段汇总去重的原理,即可完成去重的目标

d8c56ea9d46b416b0d0863da3d0aae25.gif

方法4:函数法

函数公式:

=INDEX(A:A,MIN(IF(COUNTIF($E$1:E4,$A$2:$A$11),65536,ROW($A$2:$A$11))))&""

公式需要一定的基础才能理解,输入常规的去重套路,利用是否首次出现,返回对应的行列,结合INDEX交叉获取

提示:数组公式,需要使用CTRL+SHIFT+ENTER完成公式录入

6ae5c4320dff67633b8488f51b9c68cd.gif

方法5:SQL法

我们使用数据库查询语句 SQL 中的DISCTINCT来完成去重

语法:SELECT DISCTINCT 字段 FROM [表名$]

c779f88880d6845c88be01e3be95614b.gif

方法6:VBA法

我们使用VBA中的字段key唯一这个特性来完成去重功能把姓名作为key添加到字段,最后输出即可

  • 代码:
'作者:Excel办公实战Sub distinct_data() Dim d As Object, arr, i As Integer Set d = CreateObject("scripting.dictionary") arr = Range("A1").CurrentRegion.Value For i = 2 To UBound(arr) d(arr(i, 1)) = "" Next [C1] = "姓名" Range("C2").Resize(d.Count, 1) = Application.Transpose(d.keys())End Sub‍
76128f298e0223b3295793a67af3026f.gif

方法7:PQ法(Power Query)

版本限制说明 2007及以下版本无法使用,2010和2013同学需下载插件2016自带,本次演示版本2016。我们使用M函数 Table.Disctinct函数完成去重

= Table.Distinct(Excel.CurrentWorkbook(){[Name="表3"]}[Content])
3c6e1380ea42c19b9c899d5a8e4e5d8e.gif

系列往期教程:

【技巧1001-1】谁绿了Excel

【技巧1001-2】3秒搞定最大、最小、首次、最新

【技巧1001-3】批量提取姓名电话号码

【技巧1001-4】-批量提取文件名并建立超链接

【技巧1001-5】-数据透视表字段批量计数转求和,效率提高100%!

【技巧1001-6】-Excel版的AI智能处理

【技巧1001-7】-元和万元之间自由切换

【技巧1001-8】-终极指南|0基础制作工作表目录

【技巧1001-9】-看完,还不会按颜色求和就是你的不对了

【技巧1001-10】-下拉列表居然可以多选?!

头条号:Excel办公实战

欢迎关注小编,第一时间为你送上用心更新的精彩内容

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用法举例:从数据表中name字段写入VALComboBox的items,id字段写入VALComboBox的values,当从VALComboBox选择一个选项后,就可以从value属性获得相应的ID,或者写value的为某ID,VALComboBox将定位在相应的选项上;unit VALComboBox;interfaceuses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Menus, Dialogs, StdCtrls;type TValComboBox = class(TComboBox) private FValue: PString; FValues: TStrings; FOnChange: TNotifyEvent; function GetValue: string; function GetButtonValue(Index: Integer): string; procedure SetValue(const Value: string); procedure SetValues(Value: TStrings); protected procedure Change; dynamic; procedure Notification(AComponent: TComponent; Operation: TOperation); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Value: string read GetValue write SetValue; property ItemIndex; published property Values: TStrings read FValues write SetValues; property OnChange: TNotifyEvent read FOnChange write FOnChange; end;procedure Register;implementationconstructor TValComboBox.Create(AOwner: TComponent);begin inherited Create(AOwner); FValue := NullStr; FValues := TStringList.Create; style := csDropDownList;end;destructor TValComboBox.Destroy;begin DisposeStr (FValue); FValues.Free; inherited Destroy;end;procedure TValComboBox.Notification(AComponent: TComponent; Operation: TOperation);begin inherited Notification(AComponent, Operation);end;function TValComboBox.GetValue : string;begin result:=values[itemindex];end;function TValComboBox.GetButtonValue(Index: Integer): string;begin if (Index < FValues.Count) and (FValues[Index] ‘‘) then Result := FValues[Index] else if (Index < Items.Count) then Result := Items[Index] else Result := ‘‘;end;procedure TValComboBox.SetValue (const Value: string);var I : Integer;begin AssignStr(FValue, Value); if (ItemIndex < 0) or (GetButtonValue(ItemIndex) Value) then begin if (ItemIndex >= 0) then ItemIndex := -1; for I := 0 to Items.Count - 1 do begin if GetButtonValue(I) = Value then begin ItemIndex := I; break; end

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值