+ Reply to Thread
Results 1 to 2 of 2

Force Comment when Condition Met. Comment appears on the wrong cell.

  1. #1
    Registered User
    Join Date
    11-17-2020
    Location
    singapore
    MS-Off Ver
    2017
    Posts
    1

    Force Comment when Condition Met. Comment appears on the wrong cell.

    Hi,

    I have a force comment when the formula value reaches the condition.
    the problem is the comment appears on the cell where the value was changed.
    can help to force the comment to appear on a specified cell?

    this is what I have...


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Str As String
    Dim cmt As Comment
    On Error Resume Next
    If Not Intersect(Target, Range("E5:E37")) Is Nothing Then

    Range("e3").Formula = "=f3-d3"
    If Range("e3").Value > 0.2 Then
    Str = InputBox("Your Manhours this month is 20% more than the previous. Comment why.")
    With Target
    .AddComment
    .Comment.Text Text:=Application.UserName & Chr(10) & Str
    End With
    Set cmt = Target.Comment
    With cmt.Shape.TextFrame.Characters.Font
    .Name = "Tahoma"
    .FontStyle = "Regular"
    .Size = 8
    End With
    End If
    End If
    End Sub

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,620

    Re: Force Comment when Condition Met. Comment appears on the wrong cell.

    The code is not well readable (see request below).
    But it seems it shall work as expected.
    If the comments are moved to the right - you may have merged cells.
    Please attach a file (a model one, not the real one with data) where it does not work.
    And now important part:


    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Last edited by Kaper; 11-19-2020 at 05:00 AM.
    Best Regards,

    Kaper

+ 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] Function to return comment from a cell, or null string if no comment
    By Monkihunta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2017, 01:01 PM
  2. [SOLVED] Show comment on mouse over cell rather than over comment icon....?
    By BellyGas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2015, 09:05 AM
  3. 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
  4. Disable Delete Comment, Edit Comment, Show/Hide Comment
    By Shanthan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2013, 06:12 AM
  5. open a comment to cell range upon true condition then removing comment on false condition
    By ferrum_equitis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 12:55 AM
  6. Force comment?
    By Pyrex238 in forum Excel Programming / VBA / Macros
    Replies: 44
    Last Post: 07-10-2007, 11:28 AM
  7. Force comment based on cell's value
    By Ricktaxx in forum Excel General
    Replies: 4
    Last Post: 05-05-2006, 02:25 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