删除特定行 [英] Deleting specific rows

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

问题描述

我必须为里程计算器生成Excel VBA宏,因此我必须保留特定名称的第一项和最后一项,并删除其间的所有值。例如:





所以我想离开前一个 Rivor Minor253 和最后一个,但所有中间的都必须删除。现在,我可以手动执行此操作,但是我有3,000多行需要花几天的时间才能完成,而且我可以生成一个宏,该宏删除重复项,但我不知道如何生成仅删除中间行的宏。



有人可以为我提供适合我的描述的宏吗?

解决方案

如果有可能,请先打开录制宏。假设 CHAINAGE 在ColumnA中的第39行中,并向下复制以适合您,请尝试:

  = OR(COUNTIF(B $ 1:B39,B39)= 1,COUNTIF(B $ 1:B39,B39)= COUNTIF(B:B,B39))

然后过滤该列以选择并删除FALSE行。


I have to generate a Excel VBA macro for a chainage calculator, so I have to leave the first entry and last entry of a specific name and delete all the values in between. For example:

EXAMPLE DATA IMAGE

So I want to leave the first Rivor Minor253 and the last Rivor Minor253, but all the middle ones must be deleted. Now, I could do this manually but I have over 3,000 rows which will take me days to complete, and I could generate a macro which deletes duplicates but I don't know how to generate one which will only delete the middle ones.

Could anyone provide me with a macro that fits my description?

解决方案

Turn on Record Macro first, if inclined to do so. Assuming CHAINAGE is in ColumnA, in Row39 and copied down to suit please try:

=OR(COUNTIF(B$1:B39,B39)=1,COUNTIF(B$1:B39,B39)=COUNTIF(B:B,B39))  

Then filter that column to select and delete rows FALSE.

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

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