Improve company productivity with a Business Account.Sign Up
Dim c As Long
For c = 1 To .Columns.Count
If Cells(1, c) <> "" And WorksheetFunction.CountA(.Columns(c)) = 1 Then
.Columns(c).Hidden = True
Open in new window
Set ws = ActiveSheet ' SELECT CURRENT SHEET
Set Rng = ws.Range("A1:ZZ65536") ' DEFINE RANGE
For Each Col In Rng.Columns ' START SEARCHING THE RANGE FOR EMPTY COLUMNS
'MsgBox (Mid(Col.Address, 2, 1))
'MsgBox (Cells(65536, Mid(Col.Address, 2, 1)).End(xlUp).Row)
If Cells(65536, Mid(Col.Address, 2, 1)).End(xlUp).Row = 1 Then
Rng.Columns(Col.Column).EntireColumn.Hidden = True ' Hide COlumn if this is empty
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.