Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Get Comment Text from Cell Comments in Excel - UDF


Bookmark and Share

This free Excel UDF outputs all text from a comment in Excel. This benefit of this UDF is that it doesn't display the comment author's name. This means that you will only see the actual comment text and not who wrote the comment. This is useful if you don't care who wrote the comments or if you don't share your workbook and so all of the comments are yours.

This function will only output comment text, so make sure to point the range cell reference to a cell that contains a comment.
Where to install the macro:  Module

UDF to Get Comment Text from Cell Comments in Excel

Function GETCOMMTEXT(rCommentCell As Range)

Dim cmnt As String

On Error Resume Next

cmnt = WorksheetFunction.Clean(rCommentCell.Comment.Text)

GETCOMMTEXT = Right(cmnt, Len(cmnt) - InStr(1, cmnt, ":", vbTextCompare))

On Error GoTo 0

End Function


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Cell Comments - Can't Seem To Be Able To Delete Or Change The Comment - Excel

View Content
I downloaded a Forecast template via the new worksheet option. Found that some cells have a Comment as to what to enter in the cell. I can't seem to be able to delete or change the comment. Have tried to right click to hide, delete but nothing happens. Are such comments protected or something. If not how does one change or delete such comments.
Note comment does not seem to be the type enterd using comment option!

Copy A Comment Into Another Cell As A Comment (not As Text) - Excel

View Content
Hi there.

I found some code that copies a comment box into another cell as text

Function MyComment(rng As Range)
Application.Volatile
Dim str As String
str = Trim(rng.Comment.Text)
'// If you want to remove Chr(10) character from string, then
str = Application.Substitute(str, vbLf, " ")
MyComment = str
End Function

But I really want to copy a comment box into another cell as a comment box, not just as text. Even better, I want to copy both text and comment from a source cell into a destination cell.

Can anyone tell me how to modify this accordingly?

I know I can do this by simply cutting the source box, and pasting it into the destination cell, but this will get pretty tedious given I have a zillion cells to deal with.

So what I want to do is say have a custom formula...say "=comment(name_ref)" that will point to whatever cell corresponds to name_ref, and then reads the text in the cell and the comment box from that cell and copies both of these to the cell that the formula is entered into.

This will also mean that the comment information isn't hardwired into a zillion different cells on the spreadsheet...i only need to update the master comments box once, and every other cell pointing to it will be updated.

Thanks for any help or pointers. I am new to macros, so try to keep anything you post as simple as possible.

Excel Master Required: Macro To Append New Text To Existing Cell Comment - Excel

View Content
Hi all, I have a macro that inserts a cell comment into the active cell, and I have adjusted the shape and font to my needs, but... what i want to be able to do is then select the cell with added comment and using same macro (ideally) append new text to the comment preserving the original text.

So ctrl K inserts new comment if no comment exists but ctrl K also opens the comment in edit mode if it already exists. Do you see?

The macro as I have it is below, any help would be much appreciated.
I await your excel mastery!

Code:

Sub AddNewCom()
     
    Dim strCommentName As String
    Dim cmnt As String
    Dim Today
    Today = Now
    cmnt = InputBox("Please enter a comment")
    strCommentName = "User:    " & cmnt & vbLf & Now
    On Error GoTo 0

  
    If Not activeCell.Comment Is Nothing Then GoTo 0
     
    With activeCell.AddComment(strCommentName)
        .Visible = False
        .Shape.AutoShapeType = msoShapeRoundedRectangle
        With .Shape.TextFrame
            With .Characters(0, Len("Greer:")).Font
                .Bold = True
                .Italic = True
                .ColorIndex = 3
            End With
        End With
    End With
    With activeCell
        .Comment.Shape.TextFrame.AutoSize = True
        .Comment.Visible = False
    End With
    
    Exit Sub
     
0:
    
    If Err.Number  0 Then MsgBox Err.Description
     
End Sub




Show Cell Value(text) In Comment Box Text, Or Mouse Tool Tip On An Gif Icon - Excel

View Content
I have a spread sheet were the area is getting very limited. I need to insert a small icon and when the mouse goes over (like it does in a form tool tip) will show the value of a cell (text value) located in another sheet in same workbook, or I was thinking inset a comment next to the icon and link the comments of the comments text to cell with the text value.

I've look the properties of this to objects and can figure it out.

Any help will be greatly appreciated.

How To Highlight Only The New Comments Added In The Comment Box - Excel

View Content
Hi,

I have an excel sheet which has comment box where the users go in and add project comments on the relevant cells. I have created a macro which copies(exports) all these comments from the comment box to Word. I need a macro which will highlight only the latest comments which were added on the comment box when exported to Word. ( So all the new additions will be highlighted in word).Please refer to the macro which currently exist.

Cheers!

Public Sub CopyActiveCommentsToWord()
Sheets("Change Calendar").Unprotect "mi"
Dim cmt As String
Dim C As Range
Dim I As Integer
Dim WordObj As Object
Dim ws As Worksheet
Dim PrintValue As Boolean
Dim res As Integer
On Error Resume Next
Err.Number = 0
res = MsgBox("Do want to view comments in Word?", _
vbYesNoCancel + vbQuestion, "Print Cell Comments")
Select Case res
Case vbYes
PrintValue = True
Case Else
Exit Sub
End Select
Set WordObj = GetObject(, "Word.Application")
If Err.Number = 429 Then
Set WordObj = CreateObject("Word.Application")
Err.Number = 0
End If
WordObj.Visible = True
WordObj.Documents.Add
With WordObj.Selection
.TypeText Text:="All Cell Comments in Sheet: " + ActiveSheet.Name
.TypeParagraph
.TypeText Text:="Date: " & Format(Now(), "dd-mmm-yy hh:mm")
.TypeParagraph
.TypeParagraph
End With
For Each ws In Worksheets
If ws.Visible = xlSheetVisible Then
For I = 1 To ws.Comments.Count
Set C = ws.Comments(I).Parent
Select Case C.EntireRow.Hidden + C.EntireColumn.Hidden
Case 0
cmt = ws.Comments(I).Text
With WordObj.Selection
If PrintValue = True Then
.TypeText Text:="Cell String: " & CStr(C.Address(0, 0, xlA1))
.TypeParagraph
.TypeText Text:="Project Type: " & Format(C.Value)
.TypeParagraph
.TypeText Text:="Project Name: " & C.Offset(0, 1).Value
.TypeParagraph
.TypeText Text:="Project Owner: " & C.Offset(0, 2).Value
.TypeParagraph
.TypeText Text:="Project Description: " & C.Offset(0, 4).Value
.TypeParagraph
.TypeText Text:="Key Dates: " & C.Offset(0, 3).Value
.TypeParagraph
.TypeText Text:="Issues/Mitigants: " & C.Offset(0, 7).Value
End If
.TypeParagraph
.TypeText Text:=cmt
.TypeParagraph
.TypeParagraph
.TypeParagraph
End With
End Select
Set C = Nothing
Next I
End If
Next ws
Set WordObj = Nothing
MsgBox "Finished Printing Comments To Word", vbInformation, _
"PrintCellComments"
Sheets("Change Calendar").Protect "mi"
End Sub

Copying Comment Text Of A Cell To An Adjacent Cell (xl2000) - Excel

View Content
I am trying to take cells with comments and copy the comments into an adjacent column (as cell text, not comments) to improve readability and allow for editting. I do not want to manually do this or print the comments on the sheet in the boxes.

I tried the following Macro after consulting this board.

Sub ConvertComment()
'
' ConvertComment Macro
'
For i = 1 To 20
Cells(i, 4) = Cells(i, 3).Comment.Text
Next i

End Sub

However I get a run time error 91 (Object Variable or With Block Variable Not Set).
Any help to fix this Macro or suggest another way of doing the above task will be appreciated.
Thanks
Peter

Get Text From Cell Comments - Excel

View Content
Hi,

I am trying to find a way to obtain the text from a comment in a cell. I need this to work similar to a lookup since the cell address will be dependant on the project number (to give the row) and the column header (to give the column).

I found a UDF on Ozgrid;

http://www.ozgrid.com/VBA/ExtractCommentText.htm

Which is cool but I just can't figure out how to create the coordinates formula to give the column and row number.

Any ideas?

Changing Cell Comment Text. - Excel

View Content
Good Afternoon

I have a worksheet and each cell has a comment attached to it and I need to change part of the comment text in each. This would take a significant amount of time to do cell by cell so I would like to change them all at once (as you can with find/replace which doesn't work on comments). Can anyone please advise if there is a way to do this. I just need to find all instances of one particular word and change it to another.

Thanks

VC

Display The Text Of A Comment In A New Cell - Excel

View Content
Is there a way to display the comment, attached to a cell, as the
'value' of the cell?

I have copied/pasted the comments to a new form (sheet) and would like
to have the comment text displayed IN the new cell. Then I can print
the sheet.

My current macro copies all comments from one sheet and pastes them
onto a second sheet. Now the new sheet shows the comment indicator,
with a blank cell. I want to replace the blank cell, with the TEXT of
the comment. Can this be done?

Thank you in advance.

JO



Dumping Comment Text Into A Cell - Excel

View Content
Greetings all.

I have just received a spreadsheet that has dozens of comments inserted all over the place (multiple cells on multiple sheets).

Would it be possible to dump all of these comments into cells on some particular sheet (one comment per cell obviously)? If so, anyone have any thoughts on how to best accomplish this?

I would prefer to not have to manually go in, show comments, copy the text and then paste that text into a cell on a worksheet.

Thanks in advance.

Kind Regards,

Sean

Random Tutorials
Bond Pricing Calculations for Simple Bonds
         - Future Value, Present Value, Interest Rate, etc.

(Intermediate)
Lookups With MATCH() and INDEX() Functions
(Intermediate)
Introduction to Making Formulas in Excel
(Easy)
IF Statement Introduction & Using Nested IF's
(Easy)
Function and Formulas Lookup in Excel
(Easy)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com