vba excel delete column
' Deletes 3rd column
ThisWorkbook.Worksheets(1).Columns(3).EntireColumn.Delete
' Deletes 3rd column of a range
Range("My_RANGE").Columns(3).EntireColumn.Delete
vba excel delete column
' Deletes 3rd column
ThisWorkbook.Worksheets(1).Columns(3).EntireColumn.Delete
' Deletes 3rd column of a range
Range("My_RANGE").Columns(3).EntireColumn.Delete
vba find column names and delete invert selection
Sub deleteIrrelevantColumns()
Dim currentColumn As Integer
Dim columnHeading As String
ActiveSheet.Columns("L").Delete
For currentColumn = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
columnHeading = ActiveSheet.UsedRange.Cells(1, currentColumn).Value
'CHECK WHETHER TO KEEP THE COLUMN
Select Case columnHeading
Case "State", "City", "Name", "Client", "Product"
'Do nothing
Case Else
'Delete if the cell doesn't contain "Homer"
If Instr(1, _
ActiveSheet.UsedRange.Cells(1, currentColumn).Value, _
"Homer",vbBinaryCompare) = 0 Then
ActiveSheet.Columns(currentColumn).Delete
End If
End Select
Next
End Sub
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us