如果所有单元都为零,请删除整个excel列 [英] Delete entire excel column if all cells are zeroed
本文介绍了如果所有单元都为零,请删除整个excel列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个大的excel表与许多列,所有数值 - 如何删除所有只有零值的列?
谢谢!
解决方案
尝试一下:
Sub ColumnKiller()
Dim wf As WorksheetFunction
设置wf =应用程序.WorksheetFunction
Dim N As Long,L As Long
ActiveSheet.UsedRange
设置r = ActiveSheet.UsedRange
nLastColumn = r.Columns.Count + r.Column - 1
对于L = nLastColumn到1步-1
如果wf.Sum(Cells(1,L).EntireColumn)= 0然后
单元格(1,L).EntireColumn.Delete
结束如果
下一个
结束子
I'm a very beginner to excel and VBA (though I have some experience with VB.Net).
Having a large excel sheet with many columns, all with numerical values - how can I delete all the columns which have only zero values?
Thanks!
解决方案
Give this a try:
Sub ColumnKiller()
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Dim N As Long, L As Long
ActiveSheet.UsedRange
Set r = ActiveSheet.UsedRange
nLastColumn = r.Columns.Count + r.Column - 1
For L = nLastColumn To 1 Step -1
If wf.Sum(Cells(1, L).EntireColumn) = 0 Then
Cells(1, L).EntireColumn.Delete
End If
Next
End Sub
这篇关于如果所有单元都为零,请删除整个excel列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文