删除excel重复列 [英] Delete excel duplicate columns

查看:181
本文介绍了删除excel重复列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为包含重复值的频率数据的不同日志条目开发excel应用程序。我正在尝试找到在同一行(第2个)的整个列范围内搜索该频率条目的方法以及是否重复条目发现然后删除该记录,否则覆盖特定记录的新条目。



我在下面举例说明:



幅度|相位|状态|幅度|相位|状态
4 MHz | 4 MHz | 4 MHz | 4 MHz | 4 MHz | 4 MHz |
-21.9603 | -133.59 | connected | -21.9603 | -133.59 | connected
-21.7973 | -132.802 | connected | -21.7973 | -132.802 | connected





例如,如果我通过跳过2列(因为它包含相同的条目记录)在第2行中找到4MHz频率值,并且在下一列中具有相似的值,则应该删除该列。

我正在尝试多个选项,但它不起作用。我将粘贴代码删除重复列,请在该代码中建议任何更正。

表格(< span class =code-digit> 2 )。范围(  D3:F& lastRow).RemoveDuplicates Columns:= Array( 1  2 ),标题:= xlYes 

解决方案

您无法使用RemoveDuplicates方法删除重复列! 您可以删除重复的行。



请参阅: Range.RemoveDuplicates Method(Excel) [ ^ ]



所以,是能够只获得唯一的行,从 D3:Fxx 范围复制数据,并将其粘贴到 A1:Cxx 中的数据下面。然后你就可以运行这段代码:

表格( 2 )。范围(  A3:C& lastRow).RemoveDuplicates Columns:= Array( 1  2  3 ),标题:= xlYes 


I am try to develop excel application for different log entries for frequency data which contain duplicate values in it.I am trying to find the way to search that frequency entry in entire column range of same row(2nd) and if duplicate entries found then remove that record else overwrite new entries of particular record.

I have give example below:

Amplitude|Phase| Status|   Amplitude|Phase  |Status
4 MHz|	4 MHz|	  4 MHz|    4 MHz   |4 MHz  |4 MHz|
-21.9603|-133.59|connected |-21.9603|-133.59|connected			
-21.7973|-132.802|connected|-21.7973|-132.802|connected	



e.g.If I found 4MHz frequency value in 2nd row with similar value in next columns by skipping 2 columns(because it contains same entry record) then that column should be deleted.
I was trying multiple options but it's not working.Below i paste code for delete duplicate columns,please suggest any correction in that code.

Sheets(2).Range("D3:F" & lastRow).RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes

解决方案

You can't delete duplicate columns via using RemoveDuplicates method! You can delete duplicate rows.

Please, see: Range.RemoveDuplicates Method (Excel)[^]

So, to be able to get only unique rows, copy data from D3:Fxx range and paste it below data placed in A1:Cxx. Then you'll be able to run this code:

Sheets(2).Range("A3:C" & lastRow).RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes


这篇关于删除excel重复列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆