Copying data and conditional formatting from one workbook to another

Wolfy1S1308

New Member
Joined
Mar 6, 2022
Messages
12
Office Version
  1. 2010
Platform
  1. Windows
I need to copy a range of cells C12:U21 from a sheet in another workbook. The other workbook has conditional formatting but when I copy, albeit successfully, there is no conditional formatting applied to 'ReportName'

Workbooks(xlsName).Worksheets("Main information").Range("C12:U21).Copy _ ------1
Workbooks(ReportName).Worksheets(TabName).Range("I3)
--------------------------------------------------------------------------------------
If I insert blank columns into 'xlsName' so that the data becomes I12:AA21

Workbooks(xlsName).Worksheets("Main information").Range("I12:AA21).Copy _ ------2
Workbooks(ReportName).Worksheets(TabName).Range("I3)

the conditional formatting is applied to 'ReportName

Is it possible to copy the conditional formatting as well as the data without requiring the insertion of columns into the data file 'xlsName'
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
There are syntax errors in the code you posted. I suggest when you post code to copy directly from your code window and paste into your post. You are missing close quotes in all of your Range references.

When you do a copy/paste, as you are doing in your code, all of the data and formats, including conditional formatting, should be pasted. However, there are situations where the conditional formatting could be rendered invalid based on the rules you are using and location of the new cells. For example, suppose you have cell in column E and you have a rule like this:

Excel Formula:
=A1="Header"

If you copy column E and paste to column B, that rule is now invalid because the cell reference A1 is no longer valid--it refers to a cell 5 columns to the left of the formatted cell but you can't go 5 columns to the left of column B. You may have something like that going on.

What conditional formatting rules are you using, including the Applies To ranges?
 
Upvote 0
Thanks
The actual Range values do have the quotes correctly applied, but thanks for pointing it out. I was trying to simplify the example as in the actual code the Range values are made up of strings and variables being in a loop.
I have looked at the Conditional Formatting and it is the formulas that are inconsistent. On that basis I assume the simplest way(or only way) is to insert empty columns into the data files
 
Upvote 0
Without knowing your actual worksheet, actual code, and actual conditional formatting rules I can't comment further.
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

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