Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Date
- Name
- Amount Owing
- Balance
- Sub DeleteSelectedColumns()
- Dim currentColumn As Integer
- Dim columnHeading As String
- For currentColumn = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
- columnHeading = ActiveSheet.UsedRange.Cells(1, currentColumn).Value
- 'Check whether to preserve the column
- Select Case columnHeading
- 'Insert name of columns to preserve
- Case "Date", "Name", "Amount Owing", "Balance"
- 'Do nothing
- Case Else
- 'Delete the column
- ActiveSheet.Columns(currentColumn).Delete
- End Select
- Next
- End Sub
Add Comment
Please, Sign In to add comment