Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel Word Wrap issue

Status
Not open for further replies.

dprayner

Programmer
Oct 14, 2002
140
US
Hi good people.

I used to have a problem that when people would cut and paste into a textbox, a new line character would appear at the end. When I populated an Excel cell with this, it created a small black square at the end. I beleive I have concurred this problem, but when I populate the cell, it forced the cell to word wrap. I have the Wrap Text option unchecked and the spreadsheet is protected. Any suggestion on how to prevent this involuntary text wrapping? DAVE
 
Have you tried to play with the Clean WorksheetFunction ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV. The Clean function doesn't seem to work.

I tried to code it in VBA, but it still seems to wrap the text.

Try opening a spreadsheet, creating a VB form with one textbox and one command button.

Cut and paste something from another application preferably non-microsoft into the textbox.

Code the command button to populate a cell on the spreadsheet (ie A1).

Disable the Wrap Text in the A1 cell first so that the cell is does not wrap.

See if you can prevent the little black square(s) (which I have) and see if the cell wrapped the text. You can also check the Wrap Text box under cell formatting and see that is is currently checked although you may have unchecked it.

DAVE
 
Code the command button to populate a cell on the spreadsheet (ie A1).
Have you tried something like this ?
[A1] = Application.Clean(Me.TextBox1.Value)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV.

It appears that the Clean function does the trick.

It seems to work real well.

I was referencing th ecell to clean instad of the textbox.

Thank you, DAVE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top