trim spaces in a cell

G

Guest

How do i trim empty spaces in a cell containing an invoice number but the
length of the invoice number in column B is of dynamic length?

For example,
Column B
123 4567-------->1234567
987 3------------>9873
5 55------------->555

Thanks.


Ringo Tan
 
N

Nick Hodge

Ringo

If there is only ever one space then the worksheet function below should
work

=REPLACE(A1,FIND(" ",A1,1),1,"")

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
D

Don

Hi Tan,

You can do this manually using the find/replace function
on the edit menu. Highlight the cells you want to change,
click Edit/Find....select "Replace"...type a space in the
top box and nothing in the bottom box..then "replace all"

HTH,

Don
 
D

Don Guillett

A sub to do all

Sub TRIMEM()
For Each C In Selection
C.Value = Application.Substitute(C, " ", "")
Next
End Sub
 

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