How can I program a macro to delete columns based on what column header contains? For example, I want to delete entire columns (including header) if the corresponding cell in the header row contains the % symbol.
Delete Whole Column If Header Contains "x"
-
-
-
-
Re: Delete Whole Column If Header Contains "x"
Hi,
THis will cycle through the first 10 columns if it finds % in the top cell it will delete the column.
Does that help?
Edit: I think filo's method above is better.
-
Re: Delete Whole Column If Header Contains "x"
thank you!
-
Re: Delete Whole Column If Header Contains "x"
thank you both.
-
Re: Delete Whole Column If Header Contains "x"
A compromise that does all columns without checking every column.
[vba] Dim A As Range
Do
Set A = Rows(1).Find(What:="%", LookIn:=xlValues, lookat:=xlPart)
If A Is Nothing Then Exit Do
A.EntireColumn.Delete
Loop
[/vba] -
Re: Delete Whole Column If Header Contains "x"
Quote from Andy PopeA compromise that does all columns without checking every column.
[vba] Dim A As Range
Do
Set A = Rows(1).Find(What:="%", LookIn:=xlValues, lookat:=xlPart)
If A Is Nothing Then Exit Do
A.EntireColumn.Delete
Loop
[/vba]Now were talking. : D