truncate text using VBA Excel

M

maehe

Hi,

I've got a progam running in CL (AS400) that exports a file into a cs
file. This file contains names of other files that I wish to open. Th
problem being these fiels have a fixed length of 10 and are filled wit
blanks if the text is not long enough to fill the 10 characters.

This cause a problem when joining field with ".csv".

Eg "EEC1 " & ".csv" I get "EEC1 .csv", and I want
"EEC1.csv"

Is there a way to do this.

Thanks

Eve Emer
 
R

Ron de Bruin

You can use the Trim function

Sub test()
For Each cell In Columns("A").SpecialCells(xlCellTypeConstants)
cell.Value = Trim(cell.Value)
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