Can you conditional format cells with comments?

mona4

Board Regular
Joined
Sep 15, 2004
Messages
191
Hi Please can anyone tell me if it is possible to use conditional formatting on cells which have comments so that they change a specific colour depending on the comment.

Thanks
Mona
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You could use this custom function:

Code:
Function CommentText(Cell As Range, Txt As String) As Boolean
    Dim x As Comment
    Set x = Cell.Comment
    If x Is Nothing Then
        CommentText = False
    Else
        CommentText = x.Text Like "*" & Txt & "*"
    End If
End Function

like this:

=CommentText(A1,"abc")

where A1 is the cell you want to format and "abc" is in the comment's text.
 
Upvote 0
In Conditional Formatting, Formula is.

In case you don't know how to create a custom function ...

Press Alt+F11 to access the Visual Basic Editor. Click your workbook in the Project window and choose Insert|Module from the menu. Paste my code in the window on the right. Press Alt+F11 again to return to your workbook. Then you can use the function in a cell or as a formula in Conditional Formatting.
 
Upvote 0
"=CommentText(A1,"abc")

How can i change this so this applies to the entire column and not one cell

Also,
Once i have copied the code in VB Editor and put the text above in conditional formatting, do i just run the code?
 
Upvote 0
Select the entire column and make sure A1 is the active cell. Then choose Format|Conditional Formatting, choose Formula is, paste the formula into the formula box, choose the Format and click OK twice. The A1 is a relative reference so the formula will automatically adjust for the other cells selected.

You don't need to run the code. It is a function that you have used as above.
 
Upvote 0
I have done as you said and formatted to highlight the cell, but it doesnt work, what could i be doing wrong
 
Upvote 0
It could be that none of your comments contain the text "abc". You need to change that to the text you are looking for.
 
Upvote 0
mona4 said:
I have done as you said and formatted to highlight the cell, but it doesnt work, what could i be doing wrong
You may also want to make sure you're doing a recalc [F9] after setting your formatting.
 
Upvote 0
Hi

Even though i change "ABC" to the text i need, it still doesnt highlight, i have checked over and over and nothing happens....

any other suggestions?
 
Upvote 0

Forum statistics

Threads
1,223,961
Messages
6,175,652
Members
452,664
Latest member
alpserbetli

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