+ Reply to Thread
Results 1 to 15 of 15

How to Get the Text from Notes (Comments)

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    How to Get the Text from Notes (Comments)

    I am trying to set up a macro that will save Notes (comments) that are in a worksheet, and then (after that worksheet is cleared and repopulated) restore those same Notes. This is necessary because the PayrollSheet has a column for each employee ID, and repopulating the sheet inserts new employee IDs, so Notes need to be restored based on the employee ID (which may be in a different column than it was previously).
    Unfortunately, when I try to read / save the text for a Note, I get a 1004 runtime error.
    Macro code I'm using is:
    Please Login or Register  to view this content.
    The error 1004 occurs at the CommentsSheet.Cells(WriteRowC, CommentColC) = c.Comment.Text line. The two previous lines (which use the cell's column and row numbers) work fine, so c is referring to a specific cell (and when stepping through the code manually, it is indeed referring to a cell which has a Note attached).
    Apparently, Comment.Text can be used to SET the text in a comment, but not to READ the text in a comment.
    For clarification, I am referring to NOTES (which are called Comments in VBA), not to "COMMENTS" (which are called CommentsThreaded in VBA). Talk about confusing!!!
    So, how can I READ (and save) the text in a Note / "Comment"?

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: How to Get the Text from Notes (Comments)

    Maybe post a sample workbook, the code is hard to decipher without knowing what your variables are referring to.

    Check out the yellow banner at the top of the screen

  3. #3
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    Well, I created a sample file to post in here, and (lo and behold) the macro code works fine (with NO runtime error) in that sample file!
    So I guess I will have to dig a little deeper to figure out what's going on in my main file.

  4. #4
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: How to Get the Text from Notes (Comments)

    I think it would be merged cell.

    Try this code..
    Please Login or Register  to view this content.
    You made my day!

  5. #5
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    RhiSJ, thanks for the suggestion, but there are not merged cells in the file I'm working with.

  6. #6
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: How to Get the Text from Notes (Comments)

    Could you please upload your mocked file?

  7. #7
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    Here is the greatly simplified sample file, but as I noted, the macro works as expected in this file, while I still get the Error 1004 in the original file.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: How to Get the Text from Notes (Comments)

    This file has no errors.
    Please upload errorous file...

  9. #9
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    Can't upload the bad file, due to confidential data. I will have to peruse it on my own.

  10. #10
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: How to Get the Text from Notes (Comments)

    You can delete all contents, only need errornous notes.

  11. #11
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    When I delete the sensitive data, I get the sample file (that works OK).

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,966

    Re: How to Get the Text from Notes (Comments)

    Do you have any comments that start with characters that could be interpreted as starting formulas, like - + or =?
    Everyone who confuses correlation and causation ends up dead.

  13. #13
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    YES!!! That's the problem, I think. In the actual data, the comments are preceded by =====. THANKS for that insight!!!

  14. #14
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: How to Get the Text from Notes (Comments)

    I think it's not a problem from the comment, it's from Cell contents.
    Please add a apostrophe at the front of cell value.
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: How to Get the Text from Notes (Comments)

    Good idea! I will try that!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Comments (or Notes) on Calendar
    By EdWoods in forum Excel General
    Replies: 3
    Last Post: 02-06-2024, 06:33 AM
  2. Convert Threaded Comments to Notes
    By exceltrainee314 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-20-2022, 05:31 AM
  3. Replies: 11
    Last Post: 11-01-2022, 11:33 AM
  4. Disabling notes/comments using VBA
    By Rob Wood in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-02-2020, 04:57 PM
  5. [SOLVED] Pulling Comments instead of Notes
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2020, 10:24 AM
  6. [SOLVED] Notes and Comments
    By Chupasur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-13-2019, 04:10 AM
  7. Notes (not Comments)
    By daniels012 in forum Excel General
    Replies: 3
    Last Post: 01-18-2005, 01:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1