Input box to insert comments to active cell

csmltd

New Member
Joined
Apr 12, 2013
Messages
6
Morning All

Can anyone help with the following code that I have Spliced Together. Im tring to use a input box to insert a comment to the active cell on the worksheet, this is what i Have so far:

Code:
Sub Macro6()
'
' Macro6 Macro
'
' Keyboard Shortcut: Ctrl+n
Dim cmt As Comment
  Dim newcomment As String
  Set cmt = ActiveCell.Comment
     
newcomment = InputBox("Enter your comment", "Comments", Default)
With Target.AddComment
    .Visible = False
    .Text newcomment
    End With
    'type to add comment text to selected shape
  cmt.Visible = True
End Sub

The Code opens up the comment box, but I dont know how to referance the active cell as the Target Cell to insert the comment. any help would be appreciated

Best regards

Mark
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try

Code:
Sub Macro6()
'
' Macro6 Macro
'
' Keyboard Shortcut: Ctrl+n
  Dim newcomment As String
     
newcomment = InputBox("Enter your comment", "Comments", Default)
ActiveCell.NoteText Text:=newcomment
ActiveCell.Comment.Visible = True
End Sub
 
Upvote 0
Here is a variation on what you asked for, it allows additional comments to be added to existing comments as well as creating a new comment in the active cell.

Further, you may tweak the code to change font if required.

Code:
Sub Comment()

    'Acknowledgments to MickG 11 May 2010
    
    Dim ans As String, oComment, Cmnt As String
    
    Cmnt = InputBox("Please enter a comment")
    With ActiveCell
        If .Comment Is Nothing Then
              .NoteText Cmnt
        Else
             ans = MsgBox("Yes = Add" & Chr(10) & "No = Replace ", vbYesNo + vbInformation)
              If ans = vbYes Then
                  oComment = .Comment.Text
                 .NoteText oComment & Chr(10) & Cmnt
              ElseIf ans = vbNo Then
                  .NoteText Cmnt
           End If
       End If
    End With

   
    ActiveCell.Comment.Shape.TextFrame.Characters.Font.Size = 12
    ActiveCell.Font.FontStyle = "MS Reference Sans Serif"
    ActiveCell.Font.Bold = True
    ActiveCell.Comment.Visible = False
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,003
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top