VBA Code to Hide All Columns Except Selected in Excel

This code hides all the columns in the active worksheet except for the selected range of columns.

VBA Code:

Sub HideAllColumnsExceptSelected()
    Dim allColumns As Range
    Dim selectedColumns As Range
    Set allColumns = Columns
    Set selectedColumns = Selection
    allColumns.Hidden = True
    selectedColumns.Hidden = False
End Sub

Check All VBA Codes

Join Our Telegram Group techguruplus telegram group Join Our WhatsApp Group techguruplus whatsapp group

Leave a Comment