FormatCondition = True?

macdian

New Member
Joined
Dec 10, 2003
Messages
24
Hi,

I'm trying to use a macro to delete a cell if it IS conditional formatted.

It seems right now that the colorvalue of the font is NOT stored in Font.ColorIndex, and so my IF statement based on that is not working either.

Here's the statement I am trying to use:

Code:
Public Sub DeleteHighlighted()
Set rng = Selection
For Each c In rng
        If c.FomratCondition = True Then
           c.Clear
        Else
        End If
    Next c
End Sub

edit: This is the formula I'm using for the conditional format:

=COUNTIF($V:$V,U1)>0

Help is much appreciated!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
macdian said:
Hi,

I'm trying to use a macro to delete a cell if it IS conditional formatted.

It seems right now that the colorvalue of the font is NOT stored in Font.ColorIndex, and so my IF statement based on that is not working either.

Here's the statement I am trying to use:

Code:
Public Sub DeleteHighlighted()
Set rng = Selection
For Each c In rng
        If c.FomratCondition = True Then
           c.Clear
        Else
        End If
    Next c
End Sub

edit: This is the formula I'm using for the conditional format:

=COUNTIF($V:$V,U1)>0

Help is much appreciated!

would something like this work for you?

Sub del_cond_form()
ActiveCell.SpecialCells(xlCellTypeAllFormatConditions).Select
Selection.FormatConditions.Delete
End Sub
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,239
Conditional formatting does not change the actual format properties of a cell; it just looks like it does. Try clearing the cells based on the condition of V:V and U (whatever it is you are COUNTIF'ing). Also, there's no need for an Else clause in your If block because the condition is either met or it isn't, which means if it isn't the loop will move on to the next cell anyway.
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web

ADVERTISEMENT

just beware that it will delete all conditional formats! :eek:
 

macdian

New Member
Joined
Dec 10, 2003
Messages
24
Actually, I thought it worked, but it just removes the formatting. Unfortunately, I need to clear any cell that IS formatted, or satisfies the above formula...I guess.

Macdian
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web

ADVERTISEMENT

so you want to clear the conditional formatting and the contents?

or just the contents?
 

macdian

New Member
Joined
Dec 10, 2003
Messages
24
But...thanks very much for the effor Zack. This message board is truly full of wonderful people such as yourself.

Macdian
 

macdian

New Member
Joined
Dec 10, 2003
Messages
24
What I want to do is if a Cell's conditional formatting is Active (ie, the cell is BOLD and RED...as I've made in my formatting)...I want to delete the contents....but not any cells other than those that satisfy the conditional format.
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,239
The approach I posted does what you say you want...evaluate the cell based on the condition and clear it if it meets the condition.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,800
Messages
5,638,425
Members
417,025
Latest member
MusterDuster

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
Top