VBA AdvancedFilter 过滤和复制唯一的单元格,没有空白(空)单元格 [英] VBA AdvancedFilter Filter and copy unique cells without blank (empty) cells

查看:228
本文介绍了VBA AdvancedFilter 过滤和复制唯一的单元格,没有空白(空)单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也是 VBA 和 stackoverflow.com 的新手

我正在使用此代码删除列中的重复单元格,我将唯一单元格复制到下一列,但代码对唯一数据的空非空白单元格进行计数.好的,但我不需要在新列中复制空单元格.

ActiveSheet.Range("BA4:BA59").AdvancedFilter _操作:=xlFilterCopy,_CopyToRange:=ActiveSheet.Range("BB4"), _唯一:=真

我搜索并找到了

SkipBlanks:=True

,但是当我添加它时,代码就不行了;)

请告诉我如何跳过空格和 "" cels具有重复项的列包含 IF 公式 IF(A4="打印";"用于打印的文本";"")&IF(A4="Cut";"用于剪切的文本";"")细胞中的可能结果

  1. 用于打印的文本
  2. 用于打印的文本
  3. ""
  4. 剪切文本
  5. 剪切文本

所以我只需要在新列中

  1. 用于打印的文本
  2. 剪切文本

提前致谢

解决方案

这是对以下内容的解释:

然后使用以下代码:

Range("BA4:BA9").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _"BA1:BA2"), CopyToRange:=Range("BB4"), Unique:=True

我能够做你想做的事:

I am new in VBA and stackoverflow.com too

I am using this code to remove duplicate cells in column where I copy unique cells to the next column, but code count empty non-blank cells for unique data. Ok, but I dont need to copy empty cell in the new column.

ActiveSheet.Range("BA4:BA59").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=ActiveSheet.Range("BB4"), _
UNIQUE:=True

I searched and found

SkipBlanks:=True

, but when I add it code goes to the hell ;)

Please tell me how to skip blanks and "" cels Column with duplicates contain IF formulas IF(A4="Print";"Text for printing";"")&IF(A4="Cut";"Text for cutting";"") Possible results in cells

  1. Text for printing
  2. Text for printing
  3. ""
  4. Text for cutting
  5. Text for cutting

So I need in new column only

  1. Text for printing
  2. Text for cutting

Thank you in advance

解决方案

this is an interpretation of: Advance AutoFilter to exclude certain values

Find two empty cells, I chose BA1:BA2 and put a this formula in the second of the two:

=LEN(BA5)>0

And left the first Empty.

Then using the following code:

Range("BA4:BA9").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
    "BA1:BA2"), CopyToRange:=Range("BB4"), Unique:=True

I was able to do what you want:

这篇关于VBA AdvancedFilter 过滤和复制唯一的单元格,没有空白(空)单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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