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.
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.
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.
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.
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.