MrExcel Publishing
Your One Stop for Excel Tips & Solutions

VBA


Posted by Jonny D on December 30, 2001 12:48 PM

Im locking for some code to change the font cocor on a row, say i type OK in column P i need the text to change color

Thanks


Posted by Dank on December 30, 2001 1:10 PM

If you right click the worksheet tab and choose View Code. This opens the code module for that particular worksheet in which you can enter code specific for that worksheet. Something like this might do what you need...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 16 Then Exit Sub 'Exit if not in column P

If UCase(Target) = "OK" Then Target.Font.ColorIndex = 3 'Colour the font red

End Sub

Hope it helps,
Daniel.

Posted by Jonny D on December 30, 2001 3:38 PM

Hi Daniel
Thats really good, ill be using that from now on, thus why i asked, but is it poss to have entire row coloured re same above, so OK turn red with all row, sounds silly but u have very big plans to this, and would same me agro

many thanks again
Jonny D

Posted by Dank on December 30, 2001 3:42 PM


Sure,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 16 Then Exit Sub 'Exit if not in column P

If UCase(Target) = "OK" Then Target.EntireRow.Font.ColorIndex = 3

End Sub

Regards,
Daniel.

Posted by Jack in UK on December 30, 2001 3:48 PM

Hi Daniel
I cant say a big enough thanks, so simple!
Ive learnt a few bits a big thanks

PS Both work perfectly
Jack