SOLVED
Home

Excel Conditional Formatting not functioning correctly after copying range to another sheet

%3CLINGO-SUB%20id%3D%22lingo-sub-143389%22%20slang%3D%22en-US%22%3EExcel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143389%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22thread-message-content-body-text%20thread-full-message%22%3E%0A%3CP%20class%3D%22%22%3EHi%2C%3C%2FP%3E%0A%3CP%3EI%20have%20the%20following%20situation%3A%3C%2FP%3E%0A%3CP%3ESheet%20A%20has%20many%20cells%20with%20conditional%20formatting%3A%3C%2FP%3E%0A%3CP%3E%26gt%3B%20some%20of%20these%20cells%20use%26nbsp%3B%20'formula%20to%20determine%20which%20cells%20to%20format'%3C%2FP%3E%0A%3CP%3E%26gt%3B%20other%20cells%20use%20'format%20only%20cells%20that%20contain'%3C%2FP%3E%0A%3CP%3EEverything%20works%20fine%2C%20formatting%20changes%20according%20to%20changes%20in%20the%20data!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20I%20copy%20a%20range%20of%20sheet%20A%20to%20sheet%20B%20using%20VBA%2C%20that%20works%20OK.%3C%2FP%3E%0A%3CP%3EHowever%3A%20in%20sheet%20B%20the%20conditional%20formatting%20of%20these%20cells%20is%20not%20working%20correctly%20anymore%3A%3C%2FP%3E%0A%3CP%3E%26gt%3B%20cells%20using%26nbsp%3B%20'format%20only%20cells%20that%20contain'%20work%20correct!%20formatting%20changes%20correctly%20when%20data%20changes%3C%2FP%3E%0A%3CP%3E%26gt%3B%20cells%20using%20'formula%20to%20determine%20which%20cells%20to%20format'%20do%20NOT%20work%20correctly%3A%20the%20formatting%20is%20not%20being%20changed%20when%20data%20changes....%3C%2FP%3E%0A%3CP%3ELooking%20at%20the%20conditional%20formatting%20rules%20on%20sheet%20B%3A%20everything%20looks%20fine%2C%20rules%20are%20ok%2C%20cell%20references%20are%20OK%2C%20formulas%20OK.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20using%20Excel%202013%20on%20Win%2010.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIs%20there%20any%20solution%20for%20this%20problem%3F%3F%3C%2FP%3E%0A%3CP%3EGreetings%3C%2FP%3E%0A%3CP%3EBen%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-143389%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143863%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143863%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20help!%20That%20solves%20my%20issue.%20I%20needed%20a%20small%20adjustment%20in%20my%20VBA%20copy%20code.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143483%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143483%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Ben%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20general%20yes%2C%20simple%20manual%20copy%2Fpaste%20(Ctrl%2BC%20-%26gt%3B%20Ctrl%2BV)%20transfers%20rules%20formula%20without%20referencing%20on%20source%20sheet.%20Try%20to%20test%20that%20with%20your%20data%2C%20if%20works%20you%20need%20to%20adjust%20your%20VBA%20code.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143470%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143470%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Sergei%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20your%20reply.%3C%2FP%3E%0A%3CP%3EIf%20I%20copy%20the%20formula%20it%20does%20not%20work%20correctly.%3C%2FP%3E%0A%3CP%3EHowever%2C%20by%20doing%20this%20I%20found%20out%20what%20happens%3A%3C%2FP%3E%0A%3CP%3Ethe%20original%20conditional%20formatting%20formula%20in%20sheet%20A%3A%20%22%3DABS(S38%2FS39)%26gt%3B%3DAdmin.TH.Person.high%22%3C%2FP%3E%0A%3CP%3Ebecomes%20this%20on%20sheet%20B%3A%3C%2FP%3E%0A%3CP%3E%22%3DABS(A!S38%2FA!S39)%26gt%3B%3DAdmin.TH.Person.high%22%3C%2FP%3E%0A%3CP%3ESo%3A%20the%20formula%20in%20sheet%20B%20keeps%20refering%20to%20sheet%20A.%20That%20is%20not%20what%20I%20want...%20I%20want%20to%20have%20the%20cond.%20format%20formula%20unchanged%2C%20ie.%20refering%20to%20S38%20and%20S39%20on%20sheet%20B.%20Is%20that%20possible%3F%3C%2FP%3E%0A%3CP%3EI%20overlooked%20this%20before.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143445%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143445%22%20slang%3D%22en-US%22%3E%3CP%3ECopy%20and%20Paste%20into%20a%20conditionally%20formatted%20cell%20will%20delete%20the%20rules%20in%20the%20pasted%20cells.%26nbsp%3B%20If%20you%20just%20paste%20the%20values%20or%20formulas%20using%20%3CSPAN%3ERange.PasteSpecial%20xlPasteValues%20or%20%3C%2FSPAN%3ERange.PasteSpecial%20xlPasteFormulas%2C%20the%20conditional%20formats%20should%20still%20work.%20%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-143407%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-143407%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Ben%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20copy%20the%20formula%20from%20the%20rule%20and%20use%20it%20somewhere%20in%20the%20cell%20of%20Sheet%20B%20does%20it%20work%20correctly%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-793559%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Conditional%20Formatting%20not%20functioning%20correctly%20after%20copying%20range%20to%20another%20sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-793559%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F107716%22%20target%3D%22_blank%22%3E%40Ben%20Dossche%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20it%20mean%2C%20I%20need%20to%20edit%20the%20Copy%20code%20written%20in%20VBA%20(If%20so%20can%20you%20give%20direction%20of%20how%20to%20do%20it%20%3F)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Ben Dossche
New Contributor

Hi,

I have the following situation:

Sheet A has many cells with conditional formatting:

> some of these cells use  'formula to determine which cells to format'

> other cells use 'format only cells that contain'

Everything works fine, formatting changes according to changes in the data!

 

Now I copy a range of sheet A to sheet B using VBA, that works OK.

However: in sheet B the conditional formatting of these cells is not working correctly anymore:

> cells using  'format only cells that contain' work correct! formatting changes correctly when data changes

> cells using 'formula to determine which cells to format' do NOT work correctly: the formatting is not being changed when data changes....

Looking at the conditional formatting rules on sheet B: everything looks fine, rules are ok, cell references are OK, formulas OK.

 

I'm using Excel 2013 on Win 10.

 

Is there any solution for this problem??

Greetings

Ben

6 Replies

Hi Ben,

 

If you copy the formula from the rule and use it somewhere in the cell of Sheet B does it work correctly?

Copy and Paste into a conditionally formatted cell will delete the rules in the pasted cells.  If you just paste the values or formulas using Range.PasteSpecial xlPasteValues or Range.PasteSpecial xlPasteFormulas, the conditional formats should still work.  

Hi Sergei,

Thank you for your reply.

If I copy the formula it does not work correctly.

However, by doing this I found out what happens:

the original conditional formatting formula in sheet A: "=ABS(S38/S39)>=Admin.TH.Person.high"

becomes this on sheet B:

"=ABS(A!S38/A!S39)>=Admin.TH.Person.high"

So: the formula in sheet B keeps refering to sheet A. That is not what I want... I want to have the cond. format formula unchanged, ie. refering to S38 and S39 on sheet B. Is that possible?

I overlooked this before.

 

Solution

Hi Ben,

 

In general yes, simple manual copy/paste (Ctrl+C -> Ctrl+V) transfers rules formula without referencing on source sheet. Try to test that with your data, if works you need to adjust your VBA code.

Thanks for your help! That solves my issue. I needed a small adjustment in my VBA copy code.

@Ben Dossche 

Does it mean, I need to edit the Copy code written in VBA (If so can you give direction of how to do it ?)

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
17 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
11 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies