Need to change font color

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
961
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

I would like to change the Grey color data to Black with out changing the Arrow symbol (p,q r ,are in Wingding font with Red and Green color) can anyone help me on this


Book1
ABCDEFGH
1Unaided Brand Awareness (First Mention)27-0.9-6.0 q270.4271.5
2Unaided Brand Awareness (Any Mention)470.8-6.5 q47-0.247-0.2
3Aided Brand Awareness853.6 r3.9 r851851.5
4Message Association17-2.8-3.9170.7170.5
5Book Intent - Business290.21.229-0.929-0.6
6Book Intent - Personal/Leisure5900.3590.9590.1
7Leisure Travel Consideration603.23.360260-0.2
8Business Travel Consideration9-2.5-19-2.59-4.3 q
9Affinity533.6-1.553-3.853-1.4
10Unique323.9-0.532-3.9326.0 p
11Meets Needs52-1.80.152-0.552-0.7
Sheet1
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
So r's should look like one of these? Space or no space?
1677429255063.png


Oddly enough the minus values cause Excel to complain about the formula in the cell but there doesn't seem to be one.
 
Upvote 0
You could try this on a copy of your sheet
VBA Code:
Sub ColourNumbers()
Dim Lrow As Long, Lcol As Long
Dim rng As Range

With Sheets("007") 'change to your sheet name or use With ActiveSheet
    Lrow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Lcol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End With
For Each rng In Range(Cells(1, 2), Cells(Lrow, Lcol))
    If Trim(InStr(rng, " ")) = 0 Then
        rng.Font.Color = vbBlack
    Else
        rng.Characters(1, InStr(rng, " ")).Font.Color = vbBlack
    End If
Next

End Sub
 
Upvote 0
Hi Team,

I would like to change the Grey color data to Black with out changing the Arrow symbol (p,q r ,are in Wingding font with Red and Green color) can anyone help me on this


Book1
ABCDEFGH
1Unaided Brand Awareness (First Mention)27-0.9-6.0 q270.4271.5
2Unaided Brand Awareness (Any Mention)470.8-6.5 q47-0.247-0.2
3Aided Brand Awareness853.6 r3.9 r851851.5
4Message Association17-2.8-3.9170.7170.5
5Book Intent - Business290.21.229-0.929-0.6
6Book Intent - Personal/Leisure5900.3590.9590.1
7Leisure Travel Consideration603.23.360260-0.2
8Business Travel Consideration9-2.5-19-2.59-4.3 q
9Affinity533.6-1.553-3.853-1.4
10Unique323.9-0.532-3.9326.0 p
11Meets Needs52-1.80.152-0.552-0.7
Sheet1

Hi Micron,

Thank you so much for your help and i have applied your macro and look like data color getting black but on the statement, only the 1st-word color is applied and after that statement color is in Grey.

Regards
sanjeev
 
Upvote 0
You could try this on a copy of your sheet
VBA Code:
Sub ColourNumbers()
Dim Lrow As Long, Lcol As Long
Dim rng As Range

With Sheets("007") 'change to your sheet name or use With ActiveSheet
    Lrow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Lcol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End With
For Each rng In Range(Cells(1, 2), Cells(Lrow, Lcol))
    If Trim(InStr(rng, " ")) = 0 Then
        rng.Font.Color = vbBlack
    Else
        rng.Characters(1, InStr(rng, " ")).Font.Color = vbBlack
    End If
Next

End Sub

Hi Sir,

Can we add (.0) if we have a number with 1 or 2 as 1.0 and 2.0 in after generating macro where ever we have single digit i need to add (.0)

could you please help me on this :)
 
Upvote 0
(p,q r ,are in Wingding font with Red and Green color)
I didn't code for that because you said those symbols were already coloured. I will have to adapt for 3 situations but you will have to advise which character gets which colour.
 
Upvote 0
I didn't code for that because you said those symbols were already coloured. I will have to adapt for 3 situations but you will have to advise which character gets which colour.
Sure Sir,

below is the charter has 3 different colors and in the above macro all looks good only i need .0 data if we have 1 or 2 as 1.0 and 2.0

p= Green
r= Hollow Green
q= red
 
Upvote 0
I have no idea what hollow green is and didn't find out by searching. If you don't like what I chose for a lighter green, then adjust the 153,255,153 values. In fact, you could tweak all of the colours if you use the RGB method rather than vbRed or vbGreen if you like, but I leave that to you.
This seems to work
VBA Code:
Sub ColourNumbers()
Dim Lrow As Long, Lcol As Long, i As Integer
Dim rng As Range

With ActiveSheet
     Lrow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
     Lcol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End With

For Each rng In Range(Cells(1, 2), Cells(Lrow, Lcol))
     If Not rng Is Nothing Then
         rng.Characters(1, InStr(rng, " ")).Font.Color = vbBlack
         Select Case Right(rng, 1)
             Case "p"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = vbGreen
               
             Case "q"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = vbRed
                    
             Case "r"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = RGB(153, 255, 153)
         End Select
     End If
Next

End Sub
and gives me this
1677519470532.png
 
Upvote 0
I have no idea what hollow green is and didn't find out by searching. If you don't like what I chose for a lighter green, then adjust the 153,255,153 values. In fact, you could tweak all of the colours if you use the RGB method rather than vbRed or vbGreen if you like, but I leave that to you.
This seems to work
VBA Code:
Sub ColourNumbers()
Dim Lrow As Long, Lcol As Long, i As Integer
Dim rng As Range

With ActiveSheet
     Lrow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
     Lcol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End With

For Each rng In Range(Cells(1, 2), Cells(Lrow, Lcol))
     If Not rng Is Nothing Then
         rng.Characters(1, InStr(rng, " ")).Font.Color = vbBlack
         Select Case Right(rng, 1)
             Case "p"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = vbGreen
              
             Case "q"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = vbRed
                   
             Case "r"
                 rng.Characters(InStr(rng, " ") + 1).Font.Color = RGB(153, 255, 153)
         End Select
     End If
Next

End Sub
and gives me this
View attachment 86325
Hi Sir,

Thank you so much but i can not see #.0 in the data for example cell C6 and D8 (C6 should be 0.0 and D should be -1.0) and cell G8 9.0
 
Upvote 0
I can't do any more for this. My code is based on your data and what you asked for. If the cell contains 0 and you want 0.0 then format your cells. As for G8 needing to be 9.0 when the data you supplied shows 9 then again, format your cells as you wish. All my code does is colour format your characters as you asked for. It doesn't alter formatting of cell values beyond that.
 
Upvote 1

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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