adding a comment to a cell from a textbox in a userform

Copper Contributor

Hi,

       I'm designing a simple tracking system to aid training. I have most of the form dealt with but I'm struggling with a certain component. I need a text box within the user form to input the data into a cell as a comment and not as text.Untitled-1.png

As you can see the description box will also be entering text into the same cell but there is a comment box that needs to enter longer data, more descriptive, without changing the general aesthetics of the table. I realise this is maybe a simple task for most but this is my first foray into VBA so any help would be appreciated.

1 Reply

@maxwelli1970

 

It's fairly easy, please check out this example below and find it in the attached file.

 

Private Sub CommandButton1_Click()
On Error Resume Next
Dim com As String
com = TextBox1.Text

With ActiveCell
.AddComment
.comment.Visible = False
.comment.Text Text:="Input Tracking Data:" & Chr(10) & com
End With
On Error GoTo 0
End Sub

 

Add a comment by UserForm Command.png

 

Hope that helps