Hi,
I have the following macro to delete blank columns...how could I alter this to skip the first row (not look at the header)? It thinks the column is not blank because there is a header in the first row, but the remainder of the column might not have any data. I want those deleted...
Thanks!!!
Sub DeleteROPBlanks()
'
' DeleteROPBlanks Macro
Dim Col As Long, ColCnt As Long, Rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error GoTo Exits:
If Selection.Columns.Count > 1 Then
Set Rng = Selection
Else
Set Rng = Range(Columns(1), Columns(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column()))
End If
ColCnt = 0
For Col = Rng.Columns.Count To 2 Step -1
If Application.WorksheetFunction.CountA(Rng.Columns(Col).EntireColumn) = 0 Then
Rng.Columns(Col).EntireColumn.delete
ColCnt = ColCnt + 1
End If
Next Col
Exits:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
I have the following macro to delete blank columns...how could I alter this to skip the first row (not look at the header)? It thinks the column is not blank because there is a header in the first row, but the remainder of the column might not have any data. I want those deleted...
Thanks!!!
Sub DeleteROPBlanks()
'
' DeleteROPBlanks Macro
Dim Col As Long, ColCnt As Long, Rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error GoTo Exits:
If Selection.Columns.Count > 1 Then
Set Rng = Selection
Else
Set Rng = Range(Columns(1), Columns(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column()))
End If
ColCnt = 0
For Col = Rng.Columns.Count To 2 Step -1
If Application.WorksheetFunction.CountA(Rng.Columns(Col).EntireColumn) = 0 Then
Rng.Columns(Col).EntireColumn.delete
ColCnt = ColCnt + 1
End If
Next Col
Exits:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub