Delete Active Column using VBA

Home/VBA/Delete Active Column using VBA

Excel VBA code to Delete Active Column example will help us to delete the Column in excel worksheet which is active. We can use Delete method of Columns to delete the Active Column. In this example we will see how to delete the Active Column in excel worksheet using VBA. Excel VBA Macro code for deleting Active Column macro should work for all the version of Microsoft Excel 2003, Excel 2007, Excel 2010, and Excel 2013.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


VBA Delete Active Column Excel Macro Example Code

VBA code to Delete Active Column


Here is the Example VBA syntax and Example VBA Macro code to Delete Active Column from excel worksheets. This will help you to know how to delete Active Column from Excel workbook using VBA.

VBA Delete Active Column: Syntax


Following is the VBA Syntax and sample VBA macro command to Delete Active Column from worksheet using VBA. We are using the Delete method of the Columns object of worksheet.


Columns(ActiveCell.Column).EntireColumn.Delete

Here ActiveCell.Column return the Column number of the active cell. And EntireColumn.Delete method will delete the Columns from the Excel spreadsheet.

Delete Active Column using VBA: Examples


The following Excel VBA macro code is to delete Active Column from the worksheet. This VBA macro will delete the Column which currently active.

Sub sbVBS_To_Delete_Active_Columns()
Columns(ActiveCell.Column).Delete
End Sub 

Instructions to run the VBA Macro code to delete Active Column


Please follow the below steps to execute the VBA code to delete Active Column.
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: select/ activate a cell for testing purpose
Step 6: Now press F5 to execute the code

Now you can observe that the Active Cell Column is deleted from worksheet.

Explained VBA Code to Delete Active Column


Starting program and sub procedure to write VBA code to delete Active Cell Column for worksheet.
Sub sbVBS_To_Delete_Active_Columns():
‘ActiveCell.Column returns the Active Column number.
‘And Delete method will delete the entire Column from the worksheet.
Columns(ActiveCell.Column).Delete
End Sub
Ending the Excel VBA Macro to delete the active Column.

 
 
Related Resource External VBA Reference
Excel VBA Reference Project Management Reference
VBA Reference:
Excel Reference:
By |April 22nd, 2014|VBA|0 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

Leave A Comment


Related pages


link sql to excelexcel vba beginnerexcel vba cell changevba code for excel examplesms access interview questions and answers free pdfcheckbox background colorvba sheetssaving macros in excelxml to excel converterformula for adding columns in excelvba create new worksheetif functions excel 2013data mining viva questions and answersestimate spreadsheet templatevba data entry formunprotect excel 2007how to create pivot table in excel 2003excel sendmailadvanced excel shortcuts pdfvlookup meaningexcel insert row shortcutcount if functionvba macro buttonshortcut of insert row in excelauto sort in excel without macroshow to protect specific cells in excel 2007excel vba inputhow to unlock a locked excel spreadsheethow to program vbatask timeline templateexcel vba cells valuevbscript create text filechange the width of a column in excelyes no vbavba form in excel for data entrytrend analysis chart in excelremove vbalistbox properties in vbcan you merge cells in excelhow to use excel match functionrun a query in access vbaexcel macro developmentexcel findbvba code for accesshow to enter macro in excelformula vlookup in excelwhat is meant by vlookupsql objective type questions and answers pdfreverse vlookup in excelcreate a pivot chartbuilding project management spreadsheetvba create userformunhide all rows in excel 2010dcl in dbmsprogress bar excel vbasql interview questions for experienced pdfexcel vba filefiltercountif function excel 2013ms excel rowsexcel hidden tabsmeeting recap templatetutorial pivot table excel 2007remove empty cells in excelhighlight duplicates in excelhow to sort data in excel 2007sumif exelvba objectshow to make macros in excel 2007excel macro caseclose userform vba exceldml commands in sql with syntax and examples3d plots in excelconvert xls to xml excel 2007how to combine excel worksheetssql questions and answers pdfexcel visual basic for dummies