Need help with Conditional Formatting

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
308
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to create Conditional Formatting in some of the columns of my Excel file. What I'd like it do to is change the background color of the cell to red if the value entered in the cell is not numeric, UNLESS what is entered in the cell is just blank spaces. In that instance, I don't want the conditional formatting to apply.

I have been able to figure out how to do it if the value is not numeric (thanks for the help of some forum posts), but can't figure out how to tell it to not do it if the value in the cell is just blank spaces.

Here's what I have so far. This is affecting cells E8 through E57 on the worksheet.

Screenshot (179).png


I tried creating a User Defined Function to figure out if the cell should be changed to red, but that is not a good solution for me, because whenever that runs, using Undo is no longer possible, and the people that use my file need to be able to use Undo. So I need a solution that doesn't rely on VBA code.

Another question I have is, how can I make the rule apply to other cells on the same sheet that are not directly next to the other cells. For instance, I would like this same rule to apply to these ranges: E8:E57, G8:G57, K8:K57
Do I have to create a new rule for each range, or can I have the same rule apply to all of those ranges?

Thanks in advance for any help you can offer. I don't have much experience with Conditional Formatting, and not having an easy time figuring it all out.
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
After digging around on the web some more, I found a page that I think may have pointed me in the right direction. Based on it, I came up with the formula that seemed like it would work, but it doesn't.

Here's what I came up with for "Use a formula to determine which cells to format".

If(And(ISTEXT(E8:E57),LEN(TRIM(E8:E57)<>0)))

Any thoughts on how to change the above to make it work?

And, as mentioned in my above post, I would like this to work on not only the range E8:E57, but also on other ranges within the worksheet.
 
Upvote 0
I've made a bit more progress... at least I think so. Unfortunately, it's still not working as it should.

I am trying the Conditional Formatting only on cell E8 for now, just until I get it working.

Here is what I have for the Formula for that cell in the Conditional Formatting window:
=IF(AND(ISTEXT(E8),LEN(TRIM(E8)<>0)),TRUE,FALSE)

Screenshot (182).png



Unfortunately, if the cell contains a blank space, it is still making it red.

Here's a screenshot showing the cell red while it contains a blank space, as well as the result of the two conditions in the IF statement, and the result of the entire formula.

Screenshot (181).png


Since LEN(TRIM(E8)) is returning 0, I would think the result of the full formula would be FALSE. But you can see it's still returning TRUE. So I am not sure what is wrong. Any ideas?
 
Upvote 0
Ugh. I just saw the problem. I had a ")" in the wrong place. Once I changed it, it worked. The correct formula should be:
=IF(AND(ISTEXT(E8),LEN(TRIM(E8))<>0),TRUE,FALSE)

Now that that part is solved, my other question is: how could I make this apply not only to E8:E57, but also to G8:G57 and K8:K57. Do I have to have three separate rules? Or can I do it all within the same rule? If so, can you tell me how I should change the formula?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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