Guest User

Untitled

a guest
May 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. Date
  2. Name
  3. Amount Owing
  4. Balance
  5.  
  6. Sub DeleteSelectedColumns()
  7. Dim currentColumn As Integer
  8. Dim columnHeading As String
  9.  
  10. For currentColumn = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
  11. columnHeading = ActiveSheet.UsedRange.Cells(1, currentColumn).Value
  12.  
  13. 'Check whether to preserve the column
  14. Select Case columnHeading
  15. 'Insert name of columns to preserve
  16. Case "Date", "Name", "Amount Owing", "Balance"
  17. 'Do nothing
  18. Case Else
  19. 'Delete the column
  20. ActiveSheet.Columns(currentColumn).Delete
  21. End Select
  22. Next
  23. End Sub
Add Comment
Please, Sign In to add comment