Public Sub HideEmptyColumns(ByVal mySheet As String, Optional Headers As Boolean) ' This subroutine will hide any empty columns on a worksheet ' The subroutine requires the name of a worksheet to be passed to it ' A second, optional, parameter indicates if the sheet contains headers of not. ' Sample usage : Call HideEmptyColumns("Retirement Calculator", True) ' Copyright: Abbydale Systems LLC. If IsMissing(Headers) Then ' If headers indicator is missing assume True Headers = True End If If Headers = True Then myStart = 2 ' Skip header row myDiff = 1 Else myStart = 1 myDiff = 0 End If If WorksheetExtant(mySheet) Then With Sheets(mySheet) .Activate mySheetLastRow = ThisWorkbook.Sheets(mySheet).UsedRange.Rows.Count myLastCol = .Cells(1, Columns.Count).End(xlToLeft).Column myValue = mySheetLastRow - myDiff For Y = 1 To myLastCol mySheetLastRow = mySheetLastRow If WorksheetFunction.CountBlank(Range(Cells(myStart, Y).Address(), Cells(mySheetLastRow, Y).Address())) = myValue Then .Range(Cells(Y).Address(), Cells(Y).Address()).EntireColumn.Hidden = True End If Next Y End With End If