edokhotnik
Board Regular
- Joined
- Nov 10, 2010
- Messages
- 104
Thank you in advance for your assistance. I am trying to delete entire columns in which the headers have a given text string - some attempting to use wildcards.
Excel 2010
Excel 2010
I am using the following code to do this, but can't get the wild card to work. I want to deleted all columns except for Id and any Version1*.
I am also attempting to concatenate the cells in the Version1* column if the corresponding Id is the same.
Thanks
Excel Workbook | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | JobNumber | Location | Id | Contact | Version7 | Contact1 | Version13 | ||
2 | 1 | OH | V-1234 | Abe | Autocorrect | Joshua | Remove constraints | ||
3 | 2 | SD | V-2345 | John | Build Later | Amy | Remove requirements | ||
4 | 3 | MN | V-3456 | Bill | Refine | Jane | Obtain permit | ||
5 | 4 | MN | V-3456 | Tony | Removal | Rita | Build Foundation | ||
Sheet1 |
Excel Workbook | ||||
---|---|---|---|---|
A | B | |||
1 | Id | Version13 | ||
2 | V-1234 | Remove constraints | ||
3 | V-2345 | Remove requirements | ||
4 | V-3456 | Obtain permit - Build Foundation | ||
Sheet2 |
I am using the following code to do this, but can't get the wild card to work. I want to deleted all columns except for Id and any Version1*.
Code:
Sub DelColsWildCards()
LC = Cells(1, Columns.Count).End(xlToLeft).Column
For i = LC To 1 Step -1
If Cells(1, i)<> "Id" And Cells(1, i)<> "Version1" & "*" _
Then Cells(1, i).EntireColumn.Delete shift:=xlToLeft
End If
Next i
End Sub
I am also attempting to concatenate the cells in the Version1* column if the corresponding Id is the same.
Thanks
Last edited: