PDA

View Full Version : Help creating a macro for color blind user?



callensw
02-07-2015, 01:24 PM
Hi, a colleague of mine is color blind and needs to be able to differentiate between cells with red font and black font. I have very little experience with VBA and was wondering if anyone could help me with this.

For example, if there were 50 cells, some with red and some with black font. The macro would change all of the cells with red font to bold font.

We are using Microsoft Excel 2007.

Thank you for any assistance you may offer!

gmayor
02-07-2015, 10:49 PM
You don't need a macro for this, you can do it with Replace (CTRL+H). Click the Options >> button and adjacent to the Find What window select Format > Font > Red. Adjacent to the Replacement with windows select Format > Font > Bold (set the colour to red or black as preferred). Put nothing in the text boxes and click ReplaceAll.

You can duplicate that with a macro:



Sub FontRedToBold()
Application.FindFormat.Clear
With Application.FindFormat.Font
.Color = 255
End With
Application.ReplaceFormat.Clear
With Application.ReplaceFormat.Font
.Bold = True
End With
Cells.Replace What:="", _
Replacement:="", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=True, _
ReplaceFormat:=True
lbl_Exit:
Exit Sub
End Sub

leila
02-08-2015, 01:47 AM
Hi all, I have a simple macro that just copies a row like this below. This one is executed by CtrlA on the keyboard. Code:

mikerickson
02-08-2015, 10:29 AM
This is another reason to never use color as data, only as highlight.
Mac Excel dosen't support FindFormat, so a loop like this would be used. (Although I would use underline rather than bold)

Sub trial()
Dim oneCell As Range
For Each oneCell In ActiveSheet.UsedRange
With oneCell.Font
.Bold = (.Color = 255)
End With
Next oneCell
End Sub

Note that neither of theses codes will work if the red color comes from conditional formatting. If that is the situation, changing the CF format is the way to go.

fredlo2010
02-08-2015, 08:21 PM
Hello,

This is my attempt to help with this.

Use the attached sample and run the procedure named MainCode

12834