0

How to change cell formatting based on another cell's format?

I tried the following code:

Range("A9:A9").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=LEN(A9)>40"

Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 255
    .TintAndShade = 0
End With

If Selection.FormatConditions(1).Interior.Color = 255 Then
    ActiveSheet.Range("A8").Interior.Color = 255
End If

Selection.FormatConditions(1).StopIfTrue = False
9
  • If ActiveCell.Interior.Color = 0 Then ActiveSheet.Range("A8").Interior.Color = 255
    – Michal
    Commented May 16 at 3:35
  • Thanks for reply , but seen not working yet, highlight to A8 without in range highlight.
    – Ye Lwin
    Commented May 16 at 4:01
  • Range("A9:A9").Select Range(Selection, Selection.End(xlDown)).Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=LEN(A9)>40" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 255 .TintAndShade = 0 End With If Selection.FormatConditions(1).Interior.Color = 255 Then ActiveSheet.Range("A8").Interior.Color = 255 End If Selection.FormatConditions(1).StopIfTrue = False
    – Ye Lwin
    Commented May 16 at 4:01
  • I think you should edit your question and carefully explain what you are asking for.
    – Michal
    Commented May 16 at 4:05
  • Pls explain on the specific issues you encountered. And what's your expected result?
    – taller
    Commented May 16 at 4:49

0