Need to delete columns based on Column header
Solved/Closed
Related:
- Excel vba delete column by header name
- Number to words in excel formula without vba - Guide
- Vba case like - Guide
- Delete my whatsapp account without app - Guide
- Vba select column by name ✓ - Excel Forum
- How to change author name in excel - Guide
5 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Nov 30, 2010 at 09:56 AM
Nov 30, 2010 at 09:56 AM
If you want to use this for other workbooks as well, you will have to define more ranges like:
Note that "cell", "MR" (My Range) and "MRB1" (My Range Book 1) can be changed into anything to make the code more understandable/readable for you.
Best regards,
Trowa
Sub test() Set MR = Range("A1:E1") Set MRB1 = Workbooks("Book1").Worksheets("Sheet1").Range("A1:E1") For Each cell In MR If cell.Value = "Address1" Or cell.Value = "Address2" Then cell.EntireColumn.Delete Next For Each cell In MRB1 If cell.Value = "Address1" Or cell.Value = "Address2" Then cell.EntireColumn.Delete Next End Sub
Note that "cell", "MR" (My Range) and "MRB1" (My Range Book 1) can be changed into anything to make the code more understandable/readable for you.
Best regards,
Trowa