Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Formatting text in a Cell's NoteText

From what I can tell the only code I can use to add a string as a Cell’s Note Text is Range.NoteText. Is there a way to make part of that NoteText bold? I have the strings saved as values in a Userform and as a public variable.

It is these two lines:

Cells(LR, 5).NoteText txtFld6.Value & ": " & modForms.Note1
Cells(LR, 6).NoteText txtFld6.Value & ": " & modForms.Note2

I’d like the txtFld6.Value & ": " portion to be bold since it has the employee ID of the person filling out the form.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is the full code for that Sub. From what I can tell there are more options for comments so maybe that should be my focus instead, but I just wanted to keep the way it populates as similar as possible to what we are currently doing by hand.

'Submit button Subs
Private Sub cmbSubmit_Click()

    Dim LR As Integer
    
    Set modForms.ws = ActiveWorkbook.Worksheets.Item(modForms.Assay)
    modForms.ws.Activate
    
    LR = ActiveSheet.UsedRange.Rows.Count
    If Cells(LR, 1).Value <> "" Then
        ActiveSheet.ListObjects(modForms.Assay).ListRows.Add
    End If
    
    LR = ActiveSheet.UsedRange.Rows.Count
    
    Cells(LR, 1).Value = txtRun.Value
    Cells(LR, 2).Value = txtMonth.Value & "/" & txtDay.Value & "/" & txtYear.Value
    Cells(LR, 3).Value = cbInstrument.Value
    Cells(LR, 4).Value = txtSamples.Value
    Cells(LR, 5).Value = cbCT.Value
    Cells(LR, 5).NoteText txtFld6.Value & ": " & modForms.Note1
    Cells(LR, 6).Value = cbNEGEC.Value
    Cells(LR, 6).NoteText txtFld6.Value & ": " & modForms.Note2
    Cells(LR, 7).Value = txtFld1.Value
    Cells(LR, 8).Value = txtFld2.Value
    Cells(LR, 9).Value = txtFld3.Value
    Cells(LR, 10).Value = txtFld4.Value
    Cells(LR, 11).Value = txtFld5.Value
    Cells(LR, 12).Value = txtFld6.Value
    Cells(LR, 13).Value = txtFld7.Value
    Cells(LR, 14).Value = txtFld8.Value
    
    Unload Me

End Sub 

>Solution :

Please try.

    Dim iLen As Long
    Cells(LR, 5).NoteText txtFld6.Value & ": " & modForms.Note1
    iLen = Len(txtFld6.Value) + 1
    Cells(LR, 5).Comment.Shape.TextFrame.Characters(1, iLen).Font.Bold = True

Microsoft documentation:

Comment object (Excel)

Characters object (Excel)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading