使用VBA复制范围中的所有可见和非空单元格 [英] Use VBA to copy all visible and non-empty cells in a range
本文介绍了使用VBA复制范围中的所有可见和非空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
过滤后,我要复制所有可见和非空单元格(包含文本的单元格)。由于某些原因,我当前的代码不工作。任何帮助将非常感谢。 (S2:S5000)。SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants(Sheet1)。 ).Copy
解决方案
完全承认我没有尝试代码,但您也可以尝试以下
使用表格(Sheet1)范围(S2:S5000)
Application.Intersect(.SpecialCells(xlCellTypeVisible),_
.SpecialCells(xlCellTypeConstants))复制
End With
作为开放式假设,复制的原因是粘贴到别的地方,你可以使用
更新上面的代码 With Sheets(Sheet1)。Range(S2:S5000)
Application.Intersect(.SpecialCells(xlCellTypeVisible),_
.SpecialCells(xlCellTypeConstants)) .Copy _
目标:=表格(destSheet)。范围(destRange)
结束于
$ b b
After filtering, I want to copy all visible and non-empty cells (the cells which contain text). For some reason, my current code isn't working. Any help would be greatly appreciated. Thanks!
Sheets("Sheet1").Range("S2:S5000").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Copy
解决方案
Full admission that I did not try your code, but you can also try the following
With Sheets("Sheet1").Range("S2:S5000")
Application.Intersect(.SpecialCells(xlCellTypeVisible), _
.SpecialCells(xlCellTypeConstants)).Copy
End With
Making the open ended assumption that the reason for copying is to paste somewhere else, you can update the above code by using
With Sheets("Sheet1").Range("S2:S5000")
Application.Intersect(.SpecialCells(xlCellTypeVisible), _
.SpecialCells(xlCellTypeConstants)).Copy _
Destination:= Sheets("destSheet").Range("destRange")
End With
这篇关于使用VBA复制范围中的所有可见和非空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文