Conditional Formatting (VBA)

aeddipa

Active Member
Joined
Jun 1, 2009
Messages
337
I have a code that copies a template and pastes it into another tab. However, it is copying the conditional formatting and pasting it as well. I already have conditional formatting on the other tab and do not want it to paste another set of conditional formats because the formula's are changing between the copy and pastes.

Is there a way to say in VBA do NOT copy conditional formatting?

Thanks in advance.
 
VBA accepts that line of code. So I dont know. The thing is that my current script works just fine. I have everything working other than when I click the reset button more than once it duplicated the conditional formatting and puts them in the wrong cell.

So for example cell D82 may be conditionally formatted for red fill if it doesnt match certain criteria. Well when I click reset for a second time all of a sudden D80 has that conditional format even though it SHOULDNT.

I also tried your formula and it came out really buggy. It executed, but the tab went haywire and it doesn't look right.

Like I said, I'm not looking for a new script since it does work, I just don't want the conditional formats to duplicate because they are going to the wrong cells.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Not sure how it went Haywire, or doesn't look right, and unfortunately without the sheets, it's a bit difficult to try to track it down..
 
Upvote 0
I understand. Thanks for the help anyway. I would post some of my work, but some of the information in the sheets is confidential.
 
Upvote 0
Is there anyway that I could create a macro where I could remove all conditional formats. Then each time before I was to reset my data I could remove the formats so that when I hit the reset it would only apply once?
 
Upvote 0
Check whether this does what you need :-

Code:
Dim rng As Range, area As Range
Worksheets.Add.Name = "tempD"
Sheets("Portfolio").Cells.Copy Sheets("tempD").Cells
Sheets("Template").Cells.Copy Sheets("Portfolio").Cells
Sheets("Portfolio").Cells.FormatConditions.Delete
Set rng = Sheets("tempD").Cells.SpecialCells(xlCellTypeAllFormatConditions)
For Each area In rng.Areas
    area.Copy
    Sheets("Portfolio").Range(area.Address).PasteSpecial Paste:=xlPasteFormats
Next
Application.DisplayAlerts = False
Sheets("tempS").Delete

Application.DisplayAlerts = true
 
Last edited:
Upvote 0
I actually solved my problem. Thank you for the help though and attempt to work on it. I greatly appreciate it.
 
Upvote 0

Forum statistics

Threads
1,216,070
Messages
6,128,613
Members
449,460
Latest member
jgharbawi

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