VBA code to Delete multiple Columns example will help us to delete multiple Columns from excel worksheet. We can use Delete method of Columns to delete the multiple Columns. In this example we will see how to delete the multiple Columns in excel worksheet using VBA. VBA code for deleting multiple Columns macro should work for all the version of Microsoft Excel 2003, Excel 2007, Excel 2010, and Excel 2013.
VBA code to delete multiple Columns
Here is the Example VBA syntax and Example VBA Macro to delete multiple Columns from excel worksheets. This will help you to know how to delete specific and multiple Columns from Excel workbook using VBA.
VBA Delete multiple Columns: Syntax
Following is the VBA Syntax and sample VBA code to delete multiple Columns from worksheet using VBA. We are using the Delete method of the Columns object of worksheet.
Here Column Names are your Column Names to delete. And EntireColumn.Delete method will delete the Entire Columns from the Excel spreadsheet.
Delete multiple Columns using VBA: Examples
The following VBA code is to delete multiple Columns from the worksheet. This code will delete the multiple Columns (A to C) which we have mentioned in the code.
Sub sbVBS_To_Delete_Multiple_Columns ()
Instructions to run the VBA code to delete multiple Columns
Please follow the below steps to execute the VBA code to delete multiple Columns from worksheets.
Step 1: Open any existing Excel workbook
Step 2: Press Alt+F11 – This will open the VBA Editor
Step 3: Insert a code module from then insert menu
Step 4: Copy the above code and paste in the code module which have inserted in the above step
Step 5: enter some sample data in Column A to E
Step 6: Now press F5 to execute the code
Now you can observe that the entire Columns from A to C are deleted from worksheet.
Explained VBA Code to Delete Multiple Columns:
Starting program and sub procedure to write VBA code to delete entire Column from sheet.
‘Specifying the Columns to delete and Deleting the Columns using EntireColumn.Delete method.
Ending the sub procedure to delete entire Column.
Here Columns(“A:C”) is to tell excel to delete Columns from A to C of the worksheet. And Delete method will delete the all specified Columns form the worksheet.
Delete Specific Multiple Columns using VBA: Examples
Here is the following VBA code is to delete specific multiple Columns from the worksheet. This code will delete the multiple specific Columns (A, C, H, K to O and Q to U) which we have mentioned in the code.
The above example delete the columns A, C, H, K to O and Q to U from the sheet named ‘Sheet1’.