VBA AdvancedFilter过滤并复制没有空白(空白)单元格的唯一单元格 [英] VBA AdvancedFilter Filter and copy unique cells without blank (empty) cells
问题描述
我正在使用此代码来删除列中的重复单元格,我将唯一的单元格复制到下一列,但是代码计数用于唯一数据的空白非空白单元格。好的,但是我不需要在新列中复制空单元格。
ActiveSheet.Range(BA4:BA59)。 AdvancedFilter _
pre>
动作:= xlFilterCopy,_
CopyToRange:= ActiveSheet.Range(BB4),_
UNIQUE:= True
我搜索并找到
SkipBlanks:= True
,但是当我添加代码到地狱时;)
请告诉我如何跳过空格和cels
带有重复项的列包含IF公式IF(A4 =Print;打印文本;)& IF(A4 =
- 打印文本
- 打印文本
- 切割文本
所以我只需要在新列中
- 打印文本
- 切割文本
提前谢谢
解决方案这是一个解释:
然后使用以下代码:
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
- Text for printing
- Text for printing
- ""
- Text for cutting
- Text for cutting
So I need in new column only
- Text for printing
- 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屋!