formatting individual strings in excel - excel

I'd like to learn how to use conditional formatting in Excel or, preferably, OpenOffice Calc to format a string every time it appears.
E.g., I have a table of medical structures. I want to automate italicizing and coloring the words "Superior, Inferior, Anterior, Posterior, Medial, and Lateral" as soon as the cell is finished for increased visibility and ease of reading.
So far, I only know how to change the formatting of the entire cell based on its contents, but not the specific string.
Any help would be wonderful, thanks.

You can use conditional formatting with a formula. Navigate to Conditional Formatting > New Rule > Use a formula to determine which cells to format. And then enter the formula =SEARCH("Anterior",A1,1) in the formula box. Then set the Format you'd like, using the Format button. Then click OK.
In the next window, click in the box that allows you to select which cells to apply the formatting to. Repeat this step for each word, Superior, Inferior, Anterior, Medial, etc..
A few screenshots below to clarify.

Related

Is there a way to clear a cell of any text based on the format of the cell (without formula or vba if possible)?

I'm working with numerous documents that have conditional formatting which turn a cell black if a certain value in the row is contains a specific text. The specific text varies a very often and will differ per document. When I try to write something in the black cell, it will automatically decline anything, but when I copy paste something on there it still enters the value. Because I have to copy big sets of data into these documents, I sometimes end up with values in these black cells, which can cause problems later on.
What I was wondering is if there is a way to delete any text in the cells that have the specific formatting (aka they are black) with help of the Find and Replace function or something similar.
Because I have to do it in seperate documents that I get from other people, I don't think using a formula or vba would be too practical, as I would need to manually copy it each time. But feel free to prove me wrong.
EDIT:
Hopefully this will illustrate more what my problem is.
The Background of these cells are still considered to be 'No Fill'
The conditional formatting is what causes the color
Let's assume the formatting you are trying to empty content from is yellow background cells
See image below:
Press Ctrl+H for Replace Option
Press Format Button to select the required format (yellow background)
Press Replace All
Final Result:

VBA Compare numbers and highlight if outside tolerance +/-.0005

On a brand new Excel file, I want to use commandButton_click to see if any of the numbers are ouside my tolerance (example +/- 0.0005)
IF any of the numbers are outside the tolerance, it should highlight the "wrong" cells (see picture).
Update: If someone know how I can do that in Conditional Formatting please show me. Thank you very much!
With conditional formatting you would do it as follows:
Select the cells in the range A6:O7
Click Home > Conditional Formatting > New Rule.
In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
Under Format values where this formula is true, type the formula: =ABS(A6-A1)>$D$4 (make sure the reference $D$4 corresponds to where you have the tolerance input).
Click Format, and then choose the formatting options you want to apply to values which are outside the tolerance.
Click OK on all open dialogs.
You don't need the command button with this solution, as Excel will apply the formatting immediately. Just take care not to paste formatting, because then you will destroy the above configured conditional formatting. So only paste values.
This is a slight variation of #trincot 's idea. You can create a named range which stands for tolerance and then use that for greater readability. Note that you have to do this twice, once for the upper cells and once for the lower cells:
If you haven't used named ranges before, select the two cells (A4:B4 in the screenshot) which contain the tolerance and click Create Names from Selection on the Formulas tab.

Writing a Conditional Format Formula in Excel

I am trying to write a rule in vba to trigger a Conditional Format, but I have my doubts if I am writing it correctly.
The condition for the format would be, if the cell value of a range is equal to the cell value of the same range on a different sheet:
=M7=Original!M7
This is to applied for all cells in a range (M7:BZ5000) [5000 is a large outer bound number to help conserve memory].
The issue that has me perplexed is how do I tell vba that M7=Original!M7, M8=Original!M8, Z143=Original!Z143, etc.
I feel this is a pretty basic concept but I searched these forums and could not find an answer that I think applies to my issue.
Also, Since I Would want this conditional format to trigger at the press of a button, how would I tell it to deactivate, WITHOUT removing the rest of my conditional formats (I have normal conditional formats applied to the range and want them to remain whenever the button isn't pressed.
Sheets("Main").Select
Range("M7:BZ5000").Select
For Each Cell In Selection
If Cell.Interior.Color = Excel.XlRgbColor.rgbBlack Then
Cell.Clear
End If
Next
You are using the conditional formatting choice of "Use formula to determine which cells to format"
The formula you will need is going to be like this (note the use of $ signs to control how the formula changes. The $ stops the value after it from changing)
=AND($M7=Original!$M7,$G$4="Y")
Note $G$4 is a cell you can use to turn on and off the cond. formatting. When it is "Y" the formatting will work, otehrwise any formatting you have applied will JUST be shown.
If you don't want you formatting to show when conditional formatting is on, then your conditional formatting MUST have formats the remove yours and sets them to the "default" settings.

Conditional Formatting (IF not empty)

How do I conditionally format a cell so if not blank it is grey?
I tried to do 'not equal', but it didn't work.
I am using Windows Office 2003 with Windows XP at work. I don't see the same feature as below:
What I have tried so far:
Edit: Figured what was wrong. In my production (actual work Excel), they were filled with white color. It wasn't my Excel file, so I was not aware of this before.
Does this work for you:
You find this dialog on the Home ribbon, under the Styles group, the Conditional Formatting menu, New rule....
You can use Conditional formatting with the option "Formula Is". One possible formula is
=NOT(ISBLANK($B1))
Another possible formula is
=$B1<>""
In Excel 2003 you should be able to create a formatting rule like:
=A1<>"" and then drag/copy this to other cells as needed.
If that doesn't work, try =Len(A1)>0.
If there may be spaces in the cell which you will consider blank, then do:
=Len(Trim(A1))>0
Let me know if you can't get any of these to work. I have an old machine running XP and Office 2003, I can fire it up to troubleshoot if needed.
This worked for me:
=NOT(ISBLANK(A1))
I wanted a box around NOT Blank cells in an entire worksheet.
Use the $A1 if you want the WHOLE ROW formatted based on the A1, B1, etc result.
Thanks!
This method works for Excel 2016, and calculates on cell value, so can be used on formula arrays (i.e. it will ignore blank cells that contain a formula).
Highlight the range.
Home > Conditional Formatting > New Rule > Use a Formula.
Enter "=LEN(#)>0" (where '#' is the upper-left-most cell in your range).
Alter the formatting to suit your preference.
Note: Len(#)>0 be altered to only select cell values above a certain length.
Note 2: '#' must not be an absolute reference (i.e. shouldn't contain '$').
An equivalent result, "other things being equal", would be to format all cells grey and then use Go To Special to select the blank cells prior to removing their grey highlighting.

Use different fonts in same Excel cell?

Is there any way to change the color and/or font of specific text within an excel cell? That is, I'd like one part of the cell's displayed value to be red and another part of the same cell's displayed value to be blue (as an example). Since the displayed values are being calculated as formulas, I'd need some sort of formatting formula that would apply only the stuff inside the formula. I can't seem to find anything in the text.
If you want to do this based on a formula, you will have to write some VBA. See this example
No problem. Edit the value in the formula toolbar.
Take a look at Conditional Formatting in excel.

Resources