Blue Flower

Select and Delete Certain Multiple Columns or Rows by VBA

About Hide and Unhide Rows and Columns I wrote in the tutorial on the respective link. Also on Selecting the each Nth Cell or RowNth Cell or Row I wrote to the respective tutorial.

This website is a Collection of VBA macros related to the Selection and Deletion of Specific Columns in Excel. All VBA macros in similar form there to the Internet network.

I believe that you are familiar with the basics of selecting and deleting Columns and Rows in Excel. If you have not then check out the tutorials

Selecting Certain Multiple Non-Adjacent Columns Using VBA Macro

VBA macro below selects certain Columns on Sheet1 defined range. This VBA macro copy in to Module1 of your Excel Workbook. When you start the VBA macro on Sheet1 will be selected columns A, B, E, F and G.

Sub SelectColumns1()
'select specific columns A, B, E, F and G
Application.DisplayAlerts = False
With Sheet1
Range("A:B,E:G").Select 'select specific columns A, B, E, F and G
End With
Application.DisplayAlerts = True
End Sub

After starting the VBA macros have the following situation at Sheet1 (please see image below) in which they have been selected certain non-adjacent columns.

 Select certain non adjacent columns using VBA in Excel

 

Selects Specific Columns in Excel using VBA

All VBA macros below return the same result as shown above. Therefore, selected by specific or certain columns on Sheet1. You notice different ways VBA commands for selecting columns.

Sub SelectSpecificColumns2()
'select specific columns with union range
Application.DisplayAlerts = FalseWith Sheet1Application.Union(Range("A1"), Range("B1"), Range("E1"), Range("F1"), Range("G1")).EntireColumn.Select 'select certain columns
End With
Application.DisplayAlerts = True
End Sub

 

Sub SelectSpecificColumns3()
'select specific columns with range
Application.DisplayAlerts = False
With Sheet1
Range("A1,B1,E1,F1,G1").EntireColumn.Select 'select certain columns
End With
Application.DisplayAlerts = True
End Sub

 

Sub SelectSpecificColumns4()
'select specific columns with union
Application.DisplayAlerts = False
With Sheet1
Application.Union(Columns("A"), Columns("B"), Columns("E"), Columns("F"), Columns("G")).Select 'select certain columns
End With
Application.DisplayAlerts = True
End Sub

Selecting Multiple Adjacent Columns in a Range of Excel Data

If you need to select a certain group of columns that are in the series then use VBA macro below. This VBA macro selects all the columns in Sheet1. This VBA macro copy in to Module1 of your Excel files.

Sub SelectSpecificColumnsRange5()
'Select specific adjacent columns 2,3,4,5,6 and 7
With Sheet1
'".Delete" instead ".Select" for delete columns
.Range(.Cells(1, 2), .Cells(1, 7)).EntireColumn.Select 'select columns from 2 to 7 or
End With
End Sub

 Select a series or group of adjacent columns in Excel via VBA

Delete Specific Columns in Excel using VBA

If you want to Delete Certain Columns in Excel, then use this VBA macro below. The particular VBA macro deletes columns 2,3 and 7 on Sheet1. This VBA macro, copy in the Module1 of your Excel Workbook.

Sub DeleteCertainColumns6()
'delete specific columns 2,3 and 7 on Sheet1
Dim Rng As Range
With Sheet1
Set Rng = Union(.Columns(2), .Columns(3), .Columns(7)) 'specific columns on sheet1
End With
Rng.Delete Shift:=xlToLeft 'deleting specific columns and displacement columns from right to left
'Rng.Select 'if you want select certain columns then use this command line
End Sub

Select and Remove Specific Columns and Rows in Excel

If you need to delete certain columns and rows in a range Excel spreadsheet, then use one of the VBA macros shown below. All macros return the same result. You see the differences in the VBA commands. The first and second shows the VBA macro was recorded using the Record Macro commands in the VBE.

 Select and delete specific rows and columns in Excel using VBA macros.

How You can Record the VBA Macro in Excel please see respective link.

Sub Macro1()
'recorded VBA macro in Excel, please see instructions on link above
'select and delete specific columns and rows on Sheet1
Sheets("Sheet1").Select
Range("B:B,H:H").Select 'select specific columns B and H on sheet1
Range("H1").Activate
Selection.Delete Shift:=xlToLeft 'deleting rows and displacement columns right to left
Rows("10:12").Select 'select specific rows from 10 to 12 on sheet1
Selection.Delete Shift:=xlUp 'deleting rows and displacement rows below to up
Range("A1").Select
End Sub

 

Sub Macro2()
'recorded VBA macro in Excel
'select and delete specific columns and rows on Sheet1
Sheets("Sheet1").Select
Range("B:B,H:H").Select 'select specific columns B and H on sheet1
Range("H1").Activate
Selection.Delete Shift:=xlToLeft 'deleting rows and displacement columns right to left
Range("10:10,11:11,14:14").Select 'select specific rows from 10,11 and 14 on sheet1
Range("A14").Activate
Selection.Delete Shift:=xlUp 'deleting rows and displacement rows below to up
Range("A1").Select
End Sub

 

Sub SelectAndDeleteCertainColumns2()
'select and delete specific columns and rows on Sheet1
Application.DisplayAlerts = False
With Worksheets("Sheet1")
Range("10:10, 11:11, 12:12").Select 'select specific rows on sheet1
Selection.Delete Shift:=xlUp 'deleting rows and displacement rows below to up
Range("B:B, H:H").Select 'select specific columns on sheet1
Selection.Delete Shift:=xlToLeft 'deleting rows and displacement columns right to left
End With
Application.DisplayAlerts = True
End Sub

 

Sub SelectDeleteSpecificRowsColumns3()
'select and delete certain rows and columns on Sheet1
Application.DisplayAlerts = False
With Sheet1
Range("10:10, 11:11, 12:12").EntireRow.Delete 'select and delete specific rows 10,11, and 12
Range("B:B, H:H").EntireColumn.Delete 'select and delete specific columns B and H
End With
Application.DisplayAlerts = True
End Sub

Source Internet network. All the merits of the authors mentioned VBA macros.