Get Comments UDF
VBA

UDF to Fetch Comment Text in Excel Cell

In this article, you will learn how to create a User-defined function in VBA to get the comment text from an Excel Cell. Let’s say we have attendance data on the Excel sheet and We are putting comments for the absent employees. Now if we need to fetch these comments in Excel cell to do some analysis then we can use this UDF.

Get Comments UDF
Get Comments UDF

Below is the code for this User-defined function.

Option Explicit

Function Get_Comments(rng As Range) As String
Application.Volatile
Get_Comments = rng.Comment.Text

'Remove user name

If InStr(Get_Comments, ":" & Chr(10)) > 0 Then
Get_Comments = Right(Get_Comments, Len(Get_Comments) - VBA.InStr(Get_Comments, ":" & Chr(10)) - 1)
End If

End Function

Click here to download the Practice file-

Watch the step by step video tutorial:

PK
My Name is PK. I am founder of PK-AnExcelExpert.com. I am a Microsoft Certified Professional. I have more than 10 years of experience in Data Visualization, Excel Automation and dashboard creation. Excel is my passion and I like to do always something innovative in Excel and share it with other people.
https://www.pk-anexcelexpert.com