Sub DeleteRedundantMergedColumns()
Dim col As Long
' 从右向左扫描列(避免索引错位)
For col = Columns.Count To 1 Step -1
' 检查是否为合并列且无数据
If Cells(1, col).MergeCells Then
' 取消合并
Cells(1, col).UnMerge
' 检查第2行至末尾是否为空
If Application.CountA(Range(Cells(2, col), Cells(Rows.Count, col).End(xlUp))) = 0 Then
Columns(col).Delete
End If
End If
Next col
Application.ScreenUpdating = True
End Sub
金山办公