Wednesday, September 18, 2013

How to Use VBA to Delete Columns in Excel 2007


1. Click the 'Developer' tab, click 'Visual Basic' and click the 'Insert' menu. Click 'Module' to insert a new VBA code module.
2. Type the following to create a new sub procedure:Private Sub removeColumns()
3. Type the following to remove column B from the active sheet:Columns('B:B').SelectSelection.Delete Shift:=xlToLeft
4. Edit 'B:B' in the previous step, and type the column letter you want to remove. Type 'End Sub' to end the procedure, and press 'F5' to run the procedure and remove the column.

Blogger news