Reputation: 6940
How to delete multiple columns in Excel VBA? I tried:
Sub DelColumns()
Dim col As Range
For Each col In Range("A:C,E:E,H:S,U:AK,AM:AM,AO:AU,BC:BI,BK:BV").Columns
col.EntireColumn.Delete
Next col
End Sub
Update. I try to do it on a table which is a show-detail table of pivot table. Is it possible to delete table columns without converting the table to a range first?
Upvotes: 4
Views: 39762
Reputation: 458
You can use the delete method against Range to delete columns.
In your case,
Sub DelColumns()
Range("A:C,E:E,H:S,U:AK,AM:AM,AO:AU,BC:BI,BK:BV").Delete
End Sub
Upvotes: 9