Excel/VBA - An Event that will prompt for comments


I am trying to create an event within multiple cells that would ask for a comment if certain conditions are met.
For instance:
  • If c1 < 3.2 then [run event]
  • I want the event to take the forms a comment popup that would save to a comment on the cell.


Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyMessage As String
If Intersect(Target, Range("C1")) Is Nothing Then Exit Sub
If Range("C1") < 3.2 Then
MyMessage = InputBox("Please input your comment")
With Range("C1")
    .Comment.Visible = False
    .Comment.Text Text:=MyMessage
End With
End If
End Sub

Thanks to TrowaD for this tip.
Published by deri58. Latest update on September 11, 2012 at 07:23 AM by deri58.
This document, titled "Excel/VBA - An Event that will prompt for comments," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).
Excel - Specifications and limitations of Sheets
Excel - A formula to separate data