VBA Code to format rows and columns in filtered excel sheet | Macro to format rows and columns in filtered excel sheet

VBA Code to format rows and columns in filtered excel sheet | Macro to format rows and columns in filtered excel sheet


Steps to Execute VBA Code in Excel Sheet


Step 1: Open Filtered Data Excel Sheet. 
Step 2: Press Alt + F11 on keyboard and you can see Microsoft Visual basic for applications window.
Step 3: Go to Insert Menu and select Module.
Step 4: In empty module, copy and paste below VBA code and save. (before save you must save your sheet as Macro - Enabled sheet)
Step 5: Go to the Filtered Data sheet, select rows and columns where you want to format cells and go to Developer Menu and click on macro. You ill see Find Value Macro Macro, click and run the macro.


VBA Code | Macro

Sub Unhide()
Dim Col As Range

For Each Col In Selection.EntireColumn
    If Col.Hidden = False Then
        Col.EntireColumn.AutoFit
    End If
    
Next Col

End Sub




Comments