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

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

问题描述

我在VBA和stackoverflow.com中新增了



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

  ActiveSheet.Range(BA4:BA59)。 AdvancedFilter _ 
动作:= xlFilterCopy,_
CopyToRange:= ActiveSheet.Range(BB4),_
UNIQUE:= True
pre>

我搜索并找到

  SkipBlanks:= True 

,但是当我添加代码到地狱时;)



请告诉我如何跳过空格和cels
带有重复项的列包含IF公式IF(A4 =Print;打印文本;)& IF(A4 =



  1. 打印文本

  2. 打印文本


  3. 切割文本


所以我只需要在新列中


  1. 打印文本

  2. 切割文本

提前谢谢

解决方案

这是一个解释:



然后使用以下代码:

  Range(BA4:BA9)。AdvancedFilter Action:= xlFilterCopy,CriteriaRange:= Range (_ 
BA1:BA2),CopyToRange:=范围(BB4),唯一:= 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天全站免登陆