vendredi 16 février 2018

How to bold line in one cell based on another cell in the same row

I am trying to bold the last line of a multi-line cell (column E), but specifically based on if another cell in the same row (column L) is blank/empty or not. I have working code that bolds just the last line, but trying to incorporate the IF portion has me stuck. This is what I have so far, and it keeps giving me a data mismatch error.

Thanks in advance for any help or advice.

Sub BoldLastLine1()
Dim p As Long
Dim r As Range

For Each r In ActiveSheet.Range("A3:L100")
    If Len(Trim(ActiveSheet.Cells(r, 12).Value)) <> 0 Then

        p = InStrRev(r.Value, vbLf)
        If p > 0 Then
            With r.Characters(p + 1, Len(r.Value) - p).Font
                .Bold = True
                .Size = 16
            End With
        End If
    End If
Next

MsgBox ("Updates Completed.")

End Sub

Aucun commentaire:

Enregistrer un commentaire