Trim white space off end?

J

Jason Gyetko

I have a number in a cell (pasted it there) which has a space at the end of
it Ex: "25 "

I can't perform any calculations on this number because of that space. I
tried using Value() and Trim() and I still get #VALUE! as my result. Anyone
know how this is supposed to be dealt with?
 
B

BrianB

You have probably got the cell formatted as text.

Reformat as a number. You may have to do Data/Text to columns/Finish too.

Regards
BrianB
==================================
 
J

Jim Carlock

You can try:

strText = Trim$(CStr(ActiveSheet.Cells(1,1).Value))

If you're reading from a database, make sure you account
for empty fields (which come out as Null where you can
check to see if the field is Null for a recordset). You can
NOT assign Null values to a string variable. A variant
variable might be a quick and easy solution and then you
can compare the variable against Null.
 

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