Remove many hidden excel columns with VBA (macro)

Complete Instructions

Step 1: Open VBA Editor

  1. Press Alt + F11 (opens VBA editor)

Step 2: Insert Module

  1. In the VBA editor, click InsertModule
  2. A blank code window will appear

Step 3: Paste the Macro

  1. Copy and paste this code into the module:
Sub 
DeleteBetweenCAndQY() 
Columns("D:QX").Delete 
End Sub

Step 4: Run the Macro

  1. Press F5 (or click the ▶️ Run button)
  2. The columns will be deleted immediately
  3. Press Alt + Q to close the VBA editor

Step 5: Remove the Macro

  1. Press Alt + F11 again (reopen VBA editor)
  2. In the left panel (Project Explorer), find your workbook
  3. Expand Modules folder
  4. Right-click on Module1
  5. Choose Remove Module1
  6. Click No when asked "Do you want to export before removing?"
  7. Press Alt + Q to close VBA editor

Step 6: Save Normally

  1. Press Ctrl + S to save
  2. Excel will save as a regular .xlsx file (no macro warning)

Značky