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 :-)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,739
Messages
6,180,676
Members
452,993
Latest member
FDARYABEE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top