Home>Blogs>VBA>UDF to Fetch Comment Text in Excel Cell
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
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com