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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

~Zodiac~

Board Regular
Joined
Jan 10, 2005
Messages
70
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
 

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960
In conditional formatting, try formula is:

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

Set the format to red.

HTH.
 

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
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
 

Forum statistics

Threads
1,147,690
Messages
5,742,638
Members
423,746
Latest member
Joaogomes

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
Top