Hide columns where cells in a range are blank

  • Try this

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Code
    Sub HideBlankColumns()
    ' Defines variables    Dim rng As Range, rcell As Range
    ' Defines range to check    Set rng = Range("A:A")
    ' For each cell in range    For Each rcell In rng
    ' If cell value is blank then...        If rcell.Value = "" Then
    ' It's column is hidden            rcell.EntireColumn.Hidden = True        End If
    ' Check next cell in range    Next rcell
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!