Dont fix cell colour if cell has no Interior colour or Conditional Formatting

julhs

Active Member
Joined
Dec 3, 2018
Messages
407
Office Version
  1. 2010
Platform
  1. Windows
The snippet of code below converts the applied Condition Formatting formatting rule to a FIXED format so that when
the Sub continues and the cell is subsequently copied it ONLY copies the format not the CF rule.
Slight issue with it is that it’s filling cells that have NO formatting what so ever to “White” Interior.Color which of course gets copied.
I have tried to handle it by adding an "IF" to the snippet to test for formatting; if it has its Fixed , if it doesn’t it skips it.
But I just couldn’t get the syntax right, can anyone help me out?

VBA Code:
For Each r In UsedRng
     r.Interior.Color = r.DisplayFormat.Interior.Color   ' This converts the Conditional Formatting effect to a "Fixed" static color format
     r.Font.Color = r.DisplayFormat.Font.Color   ' This keeps any Font color as it was, without it the font will be black
Next r
     UsedRng.FormatConditions.Delete   ' This deletes the CF rule from the range just converted to "Fixed" colors BEFORE range is copied
 
Brilliant Joe; now getting 100% of desired outcome.
Ha Ha , somewhat thought this question was going to be up your street.

Many thanks
Julian
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You are welcome.
Glad that we got it doing what you need!
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

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