Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-712275%22%20slang%3D%22en-US%22%3Eadding%20a%20comment%20to%20a%20cell%20from%20a%20textbox%20in%20a%20userform%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-712275%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BI'm%20designing%20a%20simple%20tracking%20system%20to%20aid%20training.%20I%20have%20most%20of%20the%20form%20dealt%20with%20but%20I'm%20struggling%20with%20a%20certain%20component.%20I%20need%20a%20text%20box%20within%20the%20user%20form%20to%20input%20the%20data%20into%20a%20cell%20as%20a%20comment%20and%20not%20as%20text.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F119976iBDCD8B15CB98F7F4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Untitled-1.png%22%20title%3D%22Untitled-1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAs%20you%20can%20see%20the%20description%20box%20will%20also%20be%20entering%20text%20into%20the%20same%20cell%20but%20there%20is%20a%20comment%20box%20that%20needs%20to%20enter%20longer%20data%2C%20more%20descriptive%2C%20without%20changing%20the%20general%20aesthetics%20of%20the%20table.%20I%20realise%20this%20is%20maybe%20a%20simple%20task%20for%20most%20but%20this%20is%20my%20first%20foray%20into%20VBA%20so%20any%20help%20would%20be%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-712275%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-715659%22%20slang%3D%22en-US%22%3ERe%3A%20adding%20a%20comment%20to%20a%20cell%20from%20a%20textbox%20in%20a%20userform%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-715659%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F364161%22%20target%3D%22_blank%22%3E%40maxwelli1970%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20fairly%20easy%2C%20please%20check%20out%20this%20example%20below%20and%20find%20it%20in%20the%20attached%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EPrivate%20Sub%20CommandButton1_Click()%3CBR%20%2F%3E%20On%20Error%20Resume%20Next%3CBR%20%2F%3E%20Dim%20com%20As%20String%3CBR%20%2F%3E%20com%20%3D%20TextBox1.Text%3CBR%20%2F%3E%3CBR%20%2F%3E%20%20With%20ActiveCell%3CBR%20%2F%3E%20%20%20.AddComment%3CBR%20%2F%3E%20%20%20.comment.Visible%20%3D%20False%3CBR%20%2F%3E%20%20%20.comment.Text%20Text%3A%3D%22Input%20Tracking%20Data%3A%22%20%26amp%3B%20Chr(10)%20%26amp%3B%20com%3CBR%20%2F%3E%20%20End%20With%3CBR%20%2F%3E%20On%20Error%20GoTo%200%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120381iE166F5715BFF5258%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Add%20a%20comment%20by%20UserForm%20Command.png%22%20title%3D%22Add%20a%20comment%20by%20UserForm%20Command.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E
maxwelli1970
Occasional Visitor

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

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
23 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies