Removing unwanted 'enter' character from comment

B

Blondegirl

Hi, on my form which adds a record to the active sheet, I have a textbox
which, if data is entered in it, will create a comment on a particular
cell with that data. I have set the textbox to Enterkeybehaviour =
true but when I view the comment later, when the enter key has been
used, as well as generating a new line, it is also creating an unwanted
character shaped like a square at the end of the line. Could someone
advise how to get rid of it. Here is my coding so far:

If TextBox4.Text <> "" Then
With ActiveSheet.Cells(Nextrow, 2).AddComment
Visible = False
Text TextBox4.Text
Shape.TextFrame.AutoSize = True
End With
End If


Thanks.
 
I

Ivan Raiminius

Hi,

does this help?

If TextBox4.Text <> "" Then
With ActiveSheet.Cells(Nextrow, 2).AddComment
..Visible = False
if instr(,textbox4.value,chr(13))<>0 then
..text worsheetfunction.substitute(textbox4.value,chr(13),"")
else
..Text TextBox4.Text
end if
..Shape.TextFrame.AutoSize = True
End With
End If

Regards,
Ivan
 
G

Guest

An easier way:
If TextBox4.Text <> "" Then
With ActiveSheet.Cells(Nextrow, 2).AddComment
..Visible = False
..Text Replace(TextBox4.Text, Chr(13), "")
..Shape.TextFrame.AutoSize = True
End With
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top