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.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It can't be paste values. I need the formulas and the format. I just don't want the conditional formatting to apply.
 
Upvote 0
Maybe having the entire code will help.

Range("G26").Select
ActiveCell.FormulaR1C1 = "=Template!RC"
ActiveWorkbook.Sheets("Template").Range("G26:AE86").Copy
ActiveWorkbook.Sheets("Portfolios").Paste
Range("G26:AE86").Select
Range("G26:AE86").Select
For Each r In ActiveWindow.RangeSelection.Rows
r.RowHeight = 13
Next r
Application.CutCopyMode = False

I'm looking to change the line that has the .Paste.


So I tried to include this in my code and it gave me an error

ActiveWorkbook.Sheets("Portfolios").Selection.PasteSpecial Paste:=xlPasteFormulas

Any suggestions?
 
Last edited:
Upvote 0
I don't think there's a way to "CONDITIONALLY" pick what formats you want to copy... a cell that's formatted bold is no different then a cell that is Conditionally formatted bold.. It's all format...
 
Upvote 0
I understand that. I am now trying to do the paste special for the formulas.

Do you know how I would implement that into my code?

Thanks for all the help you have provided.
 
Upvote 0
Code:
Range("G26").Select
ActiveCell.FormulaR1C1 = "=Template!RC"
ActiveWorkbook.Sheets("Template").Range("G26:AE86").Copy
[B][COLOR=red]ActiveWorkbook.Sheets("Portfolios").PasteSpecial Paste:=xlPasteFormulas
[/COLOR][/B]Range("G26:AE86").Select
Range("G26:AE86").Select
For Each r In ActiveWindow.RangeSelection.Rows
r.RowHeight = 13
Next r
Application.CutCopyMode = False
 
Upvote 0
Like I said above, it doesn't work when you enter

ActiveWorkbook.Sheets("Portfolios").PasteSpecial Paste:=xlPasteFormulas

into my code.

It gives me this error:

Run-Time error: 1004
Application-defined or object-defined error.

So any other ways to do this?

Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,378
Messages
6,124,603
Members
449,174
Latest member
ExcelfromGermany

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