VBA solution for color fill needed

Newbienew

Active Member
Joined
Mar 17, 2017
Messages
376
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have 12 sheets with the same conditional formatting, when I copy and paste the values from another workbook to mine, I run into an error of merged cells same size message. I thought it is easier to use a VBA for the CF, that way if I or anyone else copy and paste the regular way it will not split the CF every time. Would this be possible to turn the CF's into VBA codes and solve my issue? Link> Project App Log
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I cannot download your files from my current location (workplace security policy blocks those sites), but on the topic of merged cells, is there any way you can get rid of them?
Merged cells are probably the first feature in Excel, and cause NOTHING but issues, especially for things like VBA and sorting.
As such, most serious programmers will not touch them with 10 foot pole!

If you are using merged cells to center values among multiple columns in single rows, you can use the Center Across Selection formatting option instead of using Merged Cells to get the same visual effect, without all the issues caused by Merged Cells.
See: Tom’s Tutorials For Excel: Using Center Across Selection Instead of Merging Cells – Tom Urtis
 
Upvote 0
This is what it looks like if I did the XL2BB correctly

The CF =IF(OR($V4="REF",$V5="REF"),"TRUE","FALSE CF color is dark orange or brownish
=IF(OR($V4="PMR",$V5="PMR",$V4="TMR",$V5="TMR",$V4="DECL",$V5="DECL"),"TRUE","FALSE") CF color is red
=IF(OR($V4="C/O",$V5="C/O"),"TRUE","FALSE") CF Color is orange
=IF(OR($V4="ENL",$V5="ENL",$V4="AFF",$V5="AFF"),"TRUE","FALSE") Cf Color is green



RANGE is $A$5:$W$56

SEATTLE2-Nov-21VORHEES, JASON(123) 456-7890PHNJGFGFP. ISLD,4RE-1NOYESXYESPEN12/22/2021 HOIFEHFEFEFYESAFFYES
CHIS22-Dec-2122-Dec-21F
 
Last edited:
Upvote 0
I'll take a look at what it would for this code, but two things:

First merged cells are almost always a bad approach, as mentioned by Joe4.

Second, it is not necessary to explicitly return TRUE and FALSE with an IF statement for CF rules. If the expression evaluates to TRUE then the rule will apply, otherwise not. Also, you are returning the strings "TRUE" and "FALSE", not the boolean values TRUE and FALSE.

This

Excel Formula:
=IF(OR($V4="PMR",$V5="PMR",$V4="TMR",$V5="TMR",$V4="DECL",$V5="DECL"),"TRUE","FALSE")

can simply be this

Excel Formula:
=OR($V4="PMR",$V5="PMR",$V4="TMR",$V5="TMR",$V4="DECL",$V5="DECL")
 
Upvote 0
Thank you for the info. The format of the cells is above my pay level. For two entries they would have on merged cell, so you would have to type in yes for the first person then space bar and say yes for the second person. This is after using word wrap. There was also the issue with the phone number as well. having 2 cells and the upper one had the number in it but not the lower one.

I didn't realize i could that with the CF. I will be updating it now.
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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