computing
  • 0

Solved Excel Bold Text In Formula

  • 0

I have a simple If condition, but I want the result to be partially bolded and I dont know how

=IF(K21=0,”7. Offset with 0875 2071020059 012167 DIFF”,”7. Offset with 0875 1879902642 012167 DIFF”)

I want it to show “7. Offset with 0875 2071020059 012167 DIFF” or “7. Offset with 0875 1879902642 012167 DIFF” were “7” & “DIFF” are bold

Any advice? Thanks

Share

1 Answer

  1. re: “The amount in questions gets taken out of cell K21

    I assume that means the K21 will either be 0 or not be zero. That’s what your IF statement implies, so that’s what the code checks for.

    re: “The results gets shown on cell R27

    I changed the references to my example of A1 to be R27.

    BTW I also changed the comment lines from K1 to K21, but that was just a typo that won’t matter since comment lines don’t get executed.

    Private Sub Worksheet_Change(ByVal Target As Range)
     Application.EnableEvents = False
    'Was change made to K21?
       If Target.Address = "$K$21" Then
    'Place string if K21 = 0
          If Target = 0 Then
            Range("R27") = _
              "7. Offset with 0875 2071020059 012167 DIFF"
          Else
    'Place string if K21 <> 0
            Range("R27") = _
              "7. Offset with 0875 1879902642 012167 DIFF"
          End If
    'Format R27
        With Range("R27")
            .Font.Bold = False
            .Characters(1, 1).Font.Bold = True
            .Characters(Len(Range("R27")) - 3, 4).Font.Bold = True
        End With
       End If
     Application.EnableEvents = True
    End Sub

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    • 0