SteveOranjin
Board Regular
- Joined
- Dec 18, 2017
- Messages
- 170
Hi,
I have this great macro that removes all columns that ONLY contain a header. However, it doesn't seem to be working anymore. Sometimes also, it doesn't remove all of the columns that I thought it would.
I also have a macro set up that looks for empty cells and clears them if they are blank, but maybe thats not working.
But anyway, can someone take a look at this macro and tell me why it isn't removing columns that only contain headers?
I have this great macro that removes all columns that ONLY contain a header. However, it doesn't seem to be working anymore. Sometimes also, it doesn't remove all of the columns that I thought it would.
I also have a macro set up that looks for empty cells and clears them if they are blank, but maybe thats not working.
But anyway, can someone take a look at this macro and tell me why it isn't removing columns that only contain headers?
Code:
Sub Delete_Row_If_Only_Header() Dim col As Long
Application.ScreenUpdating = False
For col = 42 To 1 Step -1
If Application.CountA(Columns(col)) = 1 Then Columns(col).Delete
Next col
Application.ScreenUpdating = True
End Sub