+ Reply to Thread
Results 1 to 2 of 2

Create VBA Formula to Add Comment to Cell

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    California
    MS-Off Ver
    Excel 2016
    Posts
    22

    Create VBA Formula to Add Comment to Cell

    Hey everyone

    I'm looking to move a lot of comments from a large worksheet around and would really like to avoid doing so manually and rather do it through formulas.

    I am able to retrieve a cell's comment by using the VBA code as follow:

    Function GetComments(pRng As Range) As String
    If Not pRng.Comment Is Nothing Then
    GetComments = pRng.Comment.Text
    Dim CommentNow As String
    CommentNow = pRng.Comment.Text
    End If
    End Function


    I can then use the UDF =GetComments() to retrieve the comment from a cell and display it's text. I have the formula saving the text as the string CommentNow.

    I'd like to be able to then check if CommentNow is blank and if not, put the string in the current cell.

    I will be needing to use this in the form

    =IF(GetComments(Index(,Match(),Match()))="","",CellToComment(GetComments(Index(,Match(),Match())))

    I need to create the second UDF in this case called CellToComment to place the string CommentNow defined by the UDF GetComments if it is not blank.

    I've been trying and troubleshooting for far too long now. I hope someone can help. It seems like it should be simple enough.

    Additionally the cell will already have a value in it so I'd like to be able to use the formula =2816&IF(GetComments(Index(,Match(),Match()))="","",CellToComment(GetComments(Index(,Match(),Match())))

    That may be asking too much but we'll see.

    Cheers! And thanks guys
    Last edited by snolem75; 08-29-2017 at 02:57 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Create VBA Formula to Add Comment to Cell

    Can you elaborate on what you want the UDF CellToComment to do?
    Design everything to be as simple as possible, but no simpler.

+ 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] Create comment that updates based off cell change
    By earthandbody in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-21-2017, 09:06 AM
  2. Check if cell in range is empty, if it is delete comment else format comment to
    By banaanas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2015, 01:15 AM
  3. [SOLVED] Vba code that will create a cell value to become a comment
    By melanie castro in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-24-2015, 03:43 AM
  4. create comment for cell based on different cells
    By klayman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2014, 10:32 AM
  5. Macro to create comment box on any given selected cell.
    By Ben Crenshaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2013, 06:00 AM
  6. [SOLVED] Create comment box from cell values
    By elevdown in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2012, 09:02 AM
  7. Replies: 1
    Last Post: 07-25-2006, 08:20 AM

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