Spaces in data entry

J

JLR-Mart

On my user form I have several text boxes to capture user data that is
entered on the form. When it posts the contents into the excel spreadsheet it
puts a space in front of the data so that, when aligned left, it looks like
this

TEXT ALREADY IN SPREADSHEET
TEXT FROM FORM

it doesn't do it on all text boxes, just a few.

Anyone know what setting causes this?
 
M

Mike H.

Not sure of the setting, but probably is indent. But just always have your
code copy the formats from the line above after done adding new data and
problem solved!


let X=activecell.row
Let Y=activecell.column
cells(x-1,y).select
Selection.Copy
cells(x,y).select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Or globally change all data after doing your entire data entry if this slows
it down too much.
 
R

RyanH

In the future it will help to post your code so it can be viewed for the
issue you are having. Do you use Str() in your code, because this will
automatically add a space to whatever String you are adding to a worksheet?
If not, try using this:

Range("A1") = Textbox1.Text
 
J

JLR-Mart

Confused is me. The code is below:

thisrow2.Offset(0, 88).Value = PHCode.Text

so I think it must be one of the text box properties that is causing this
behaviour????
 
R

RyanH

I personally don't see a problem. Try adding a new text box to the Userform
and test it. It could be your cell formatting on the worksheet.
 
D

Dave Peterson

Maybe...

thisrow2.Offset(0, 88).Value = trim(PHCode.Text)

if there's a posibility that the user types multiple internal spaces and you
don't want that:

thisrow2.Offset(0, 88).Value = application.trim(PHCode.Text)
 
J

JLR-Mart

It is weird because other text boxes on the form do not exhibit the same
behaviour. I might delete the box and recreate from new and try that.
 

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