Excel - squares appear when sending info from textbox to cell

Hi there -

Hope someone can help! I have a simple database in Excel, driven by VB. I have a textbox in a form that, when updating the record, enters the info from the textbox into a cell (ie, range("a1").value=frmdata.txtnotes.text. The textbox uses multiline, and when it updates the cell, squares appear where the enter key was pressed in the textbox. It is identical with the .value property.

Does anybody know how to transfer the contents of the textbox, removing the squares but retaining the text format

Thanks in advance,

Chris



Answer this question

Excel - squares appear when sending info from textbox to cell

  • Rj_murray

    Thanks for that, Derek. Unfortunately, it didn't work. I tried combinations from your solutions: vbcrlf, vblf. Luckily, the following worked:

    Range("A1").Value = Replace(frmData.txtNotes.Text, vbCr, " ")

    Problem solved: many, many thanks Derek. It was really starting to get to me!

    Chris


  • adrianol

    Range("A1").Value = Replace(frmData.txtNotes.Text, vbCrLf, " ")

    That should work. If you end up with two spaces between each new line then just call the Replace function again and replace the two spaces with a single space.



  • Excel - squares appear when sending info from textbox to cell