change text to red

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
hi,

I would rather have VB to sort my issue rather than use conditional formatting, but I lack the VB knowledge & hope 'Mr Excel can sort?

so when any cell(s) within col c, contains 'Code2663' it will turn all the text in the applicable row red. The complete range is from A2:J200



many thanks in advance & your help is very much appreciated

KR
Trevor3007
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

Try:

Code:
Sub red()


Dim ws As Worksheet
Set ws = ActiveSheet

Dim r As Integer
For r = ws.UsedRange.Rows.Count To 1 Step -1
    If Cells(r, "C") = "Code2663" Then
        Sheet1.Rows(r).Font.Color = -16776961
    End If
Next


End Sub
 
Last edited:
Upvote 0
Hi,

Try:

Code:
Sub red()


Dim ws As Worksheet
Set ws = ActiveSheet

Dim r As Integer
For r = ws.UsedRange.Rows.Count To 1 Step -1
    If Cells(r, "C") = "Code2663" Then
        Sheet1.Rows(r).Font.Color = -16776961
    End If
Next


End Sub

many thanks for your help. I gave it try, but did not work:[

no errors, nothing :[

any suggs?
 
Upvote 0
Change this

Code:
If Cells(r, "C") = "Code2663" Then

to this

Code:
If Cells(r, "C") <> "Code2663" Then


Has one of your "Code2663" now changed colour?
Yes? Then your data is NOT "Code2663", thats why it didnt turn red originally.

Now change the line of code back and investigate what the data that looks like "Code2663" really is.
You can use LEN() to establish the length of the data, result should be 8, if it's something else then that data is NOT "Code2663"
 
Last edited:
Upvote 0
many thanks for your help. I gave it try, but did not work:[

no errors, nothing :[

any suggs?

hi,

many thanks again. The issue is , although the word is code2663, its looking for a upper c and not just anycase . Is it possible for it to look for the specific word , irrespectively if its upper\lower\proper case

The data is in-putted by various people...its only me who has to check.

Hoping you can sort ...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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