【发布时间】:2018-02-11 18:22:42
【问题描述】:
我刚刚使用 Autodesk 文件中的数据通过算法填充了一个表。很多字段是空的,事实上,许多列是空的,但只有几行。大约有 1300 列,我正在尝试减少它。
如果列为空的行超过 1000 行,谁能帮助我使用 VBA 删除列?我真的不知道任何 VBA,所以我不知道从哪里开始......
我正在尝试这样的事情:
Sub ClearColumns()
'
' ClearColumns Macro
' Check to see if more than 1000 rows of a column are empty. If so, delete the column.
Dim iColumn As Long
Dim iRow As Long
Dim iColumnMax As Long
Dim iRowMax As Long
Dim iEmptyCount
iColumnMax = 13000
iRowMax = 20000
For iColumn = 1 To iColumnMax
For iRow = 1 To iRowMax
If (Cells(iRow, iColumn) = "") Then iEmptyCount.Add (1)
End If
If (iEmptyCount > 999) Then Columns(iColumn).Delete
Step 1
End If
Step 1
Application.Goto Reference:="ClearColumns"
End Sub
但同样,我不知道自己在做什么。任何帮助/反馈表示赞赏
【问题讨论】:
-
但是每一列都有数百万个单元格............底部的大部分单元格都是空的!
-
好的。然后有一系列行......就像 RowMax = 20000
标签: vba excel multiple-columns