delete entire column based on color of top cell vba

Dslade1975

New Member
Joined
Oct 10, 2019
Messages
3
good morning.
long time viewer first time posting
I am having difficulty with a code to delete an entire column base on top cell color.
I supply a sample spreadhseet that has conditional formatting applied to highlight cell the equals A1.

looking for an VBA code that i can assign to a active x button if possible.

could anyone assist please, this is doing my head in :)
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,099
Office Version
2019
Platform
Windows
Conditional formatting cannot be read by VBA. What you should do is provide information for the basis of creating a conditional format. Then applying that condition to determine which columns should be deleted.
 

Dslade1975

New Member
Joined
Oct 10, 2019
Messages
3
Conditional formatting cannot be read by VBA. What you should do is provide information for the basis of creating a conditional format. Then applying that condition to determine which columns should be deleted.

thank you for the advice Alan,

would it be possible to match a text/number string in A1 and search for the matching text/number in row B:B and delete the corresponding column?
thank you , i am very knew to VBA coding and am not sure what can work
 

Dslade1975

New Member
Joined
Oct 10, 2019
Messages
3
example
1 2 3 4 5
A h001
B Title No. H001 H002 h003 h004
C text 50 34 23 18
D text 18 72 18 20

I want to refer to A1 and delete the column with the same title on row B:B
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,698
Office Version
2007
Platform
Windows
Hi @Dslade1975 and welcome to the forum!

If you want to know the color of a cell that has been colored by a conditional formatting then use

msgbox range("A1").DisplayFormat.Interior.Color
 

Forum statistics

Threads
1,085,703
Messages
5,385,330
Members
401,938
Latest member
JustinTaster

Some videos you may like

This Week's Hot Topics

Top