Comments vs Note Text Excel Add-in with code example

Comments vs Note Text Excel Add-in with code example

NoteText

Note Text method is a replaced by comments object in Excel. It behaves like comments in a cell. It is visible at the right top corner of a cell. Comments in excel inserts author information but Note Text only has text.

Syntax

Range.NoteText(Text, Start, Length)

Parameters

  1. Text: Refers to a running string which can be up to 255 character long.
  2. Start: Refers to start position from where we want to retrieve text from a NoteText.
  3. Length: Refers to number of characters you would like to retrieve from a NoteText.

VBA code example

Public Sub InsertNoteText()
    'Declare range object
    Dim oRange As Range
    
    'Bind selection to range
    Set oRange = Selection
    
    'Add note text
    oRange.NoteText Text:="www.VBAOVERALL.com is a complete solution"
    
    'Cleanup
    If Not oRange Is Nothing Then
        Set oRange = Nothing
    End If
End Sub

C# code example

private void btnInsertNoteText_Click(object sender, RibbonControlEventArgs e)
{
	//Retain selection
	excel.Range oRange = Globals.ThisAddIn.Application.Selection;

	//Insert NoteText
	oRange.NoteText(Text: "www.VBAOVERALL.com is a complete solution");
}

Output

Next >> Understand Comments in Excel with code example

Leave a Reply

Your email address will not be published. Required fields are marked *