Forum Discussion

maxwelli1970's avatar
maxwelli1970
Copper Contributor
Jun 20, 2019

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

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.

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

  • Haytham Amairah's avatar
    Haytham Amairah
    Silver Contributor

    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

     

     

    Hope that helps

Resources