Hi everyone, I'm new to VBA and I'm trying to write a macro that will delete columns based on conditional formatting.
Basically what I have is a range of cells, each cell has 2 conditional formatting criteria, both with the same conditions and
if this condition is true, then the cell is highlighted yellow and if the condition is false, the text is white colored.
What I want the macro to do is for each column in this range, check the CF of each cell, and if every cell in the column
meets the second CF criterion (ie., the text is white colored), then delete the entire column. I've found some VBA code
online for a function that checks for CF, and I'm trying to use that with some code I found for deleting blank columns.
Here's what I have so far, with the line I modified in blue:
Dim Col As Long, ColCnt As Long, Rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error Goto Exits:
If Selection.Columns.Count > 1 Then
Set Rng = Selection
Set Rng = Range(Columns(1), Columns(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column()))
ColCnt = 0
For Col = Rng.Columns.Count To 1 Step -1
[COLOR="Blue"]If Application.WorksheetFunction.CFColor(Rng.Columns(Col).EntireColumn) = 0 Then[/COLOR]
ColCnt = ColCnt + 1
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
This doesn't seem to do anything though, and since I really don't know much about VBA I thought I'd post here for some