Font colour not applied to some text

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,738
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Im using the code below.
It should work like this.
Cell G13 is a drop down where a customer is then selected.
Cell M11 is a drop down where the options to select are CAR or BIKE
Cell O14:O10 will be text shown but dependant on the above.

So all the interior colors & fonts do what should be done
BUT
My issue is when cell G13 has a customer selected & cell M11 has BIKE selected i should then see cells O14:O17 with a grey interior of which i do BUT the font colour for cell O16 is also grey where it should be Black.

See screenshot please as cell O13 shows BITING & cell O16 should say KEY TYPE but as you can see its hidden ?

In cells O13 there is the following
Rich (BB code):
=IF(M11="BIKE", "BITING", " ")

In cell O16 there is the following
Rich (BB code):
=IF(M11="BIKE", "KEY TYPE", " ")


Rich (BB code):
    If Target.Address = "$M$11" Then
    If Target.Count > 1 Then Exit Sub
    
    With Range("O14,O17")
      If Target.Value = "CAR" Then
        .Interior.Color = 12566463
        .Font.Color = 12566463
      Else
        .Interior.Color = 12566463
        .Font.Color = vbBlack
      End If
    End With
  End If
  
  If Range("M11").Value = "" Then
     With Range("O14:O17")
        .Interior.Color = 12566463
        .Font.Color = 12566463
    
    End With
    End If
 

Attachments

  • EaseUS_2023_08_13_13_08_45.jpg
    EaseUS_2023_08_13_13_08_45.jpg
    53.2 KB · Views: 9
  • EaseUS_2023_08_13_13_12_08.jpg
    EaseUS_2023_08_13_13_12_08.jpg
    89.7 KB · Views: 14

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Ok
I have narrowed it down to the piece of code which is causing the issue.
The code in blue is the issue.
@DanteAmor advised a code where the interior & font would change color etc so i followed it BUT must of missed something.

The goal here with the code in blue below is If cell M11 has no value yet selected then O14:O17 should be as background colour etc.
Only when an M11 selection is made the text is visible.



Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
    If Not Intersect(Target, Range("L14:L18,G13:G18,G27:M51")) Is Nothing Then
      Application.EnableEvents = False
      Target = UCase(Target)
      Application.EnableEvents = True
    End If
    
  If Not Intersect(Target, Range("G13")) Is Nothing Then
    Application.EnableEvents = False
    
  If Range("G13").Value <> "" Then
      Range("M11").Value = ""
    End If
    Application.EnableEvents = True
  End If
  
    If Target.Address = "$M$11" Then
    If Target.Count > 1 Then Exit Sub
    
    With Range("O14,O17")
      If Target.Value = "CAR" Then
        .Interior.Color = 12566463
        .Font.Color = 12566463
      Else
        .Interior.Color = 12566463
        .Font.Color = vbBlack
      End If
    End With
  End If
  
  If Range("M11").Value = "" Then
     With Range("O14:O17")
        .Interior.Color = 12566463
        .Font.Color = 12566463
    
    End With
    End If
End Sub
 
Upvote 0
Can you advise please who i edit the following.
Currently it runs for when cell M11 value = CAR
I would like to have the code do the same BUt not only CAR but also if not selected yet.

@DanteAmor maybe you can advise when free,Thanks
Currently when M11 is not selected it shows values in cells,see screenshot attached


Rich (BB code):
    If Target.Address = "$M$11" Then
    If Target.Count > 1 Then Exit Sub
    
    With Range("O14,O17")
      If Target.Value = "CAR" Then
        .Interior.Color = 12566463
        .Font.Color = 12566463
      Else
        .Interior.Color = 12566463
        .Font.Color = vbBlack
      End If
    End With
  End If
 

Attachments

  • EaseUS_2023_08_14_11_30_12.jpg
    EaseUS_2023_08_14_11_30_12.jpg
    16.7 KB · Views: 5
Upvote 0
This was added & did it for me.

Rich (BB code):
If IsEmpty(Range("M11").Value) = True Then
With Range("O14,O17")
.Interior.Color = 12566463
.Font.Color = 12566463
End With

End If
 
Upvote 0
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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