【发布时间】:2018-07-25 18:26:27
【问题描述】:
下面的代码删除整个列中所有空单元格的列。我需要更改它以删除整个列中所有空单元格的列,前提是存在列标题。我希望保留没有标题且没有单元格数据的列。
感谢您的帮助!
Dim X As Long, LastRow As Long, LastCol As Long
LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
LastCol = Cells(1, Columns.count).End(xlToLeft).Column
Application.ScreenUpdating = False
For X = LastCol To 1 Step -1
If Cells(1, X).Value = Join(Application.Transpose(Cells(1, X).Resize(LastRow)), "") Then Columns(X).Delete
Next
Application.ScreenUpdating = True
【问题讨论】: