Changing cell colours with macro/formula

bartoni

Active Member
Joined
Jun 10, 2003
Messages
296
In column B I have some cells with the letter N inside. How would i write a formula/macro to change all cells with the lettter N inside to go red.

Many Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
try this code

Sub MakeNRed()
'
' MakeNRed Macro

Cells.Find(What:="n", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
stophere = ActiveCell.Address
Restart:
i = 0
For i = 1 To 9999

Cells.FindNext(After:=ActiveCell).Activate
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

If ActiveCell.Address = stophere Then GoTo TheEnd:
Next i
If i > 9999 Then GoTo Restart:

TheEnd:
End Sub


It should work fine
 
Upvote 0
In conditional formatting, try formula is:

=Search("n",B1,1)>0

Set the format to red.

HTH.
 
Upvote 0
Another tack. If the cell only contains an "N", then try conditional formatting.

Also works for an occurrence of "N" within the cell. Use Formula Is and the following formula (probably not the shortest, :oops: ):

=NOT(ISERROR(SEARCH("n",B3)))=TRUE
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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