truncate text using VBA Excel

  • Thread starter Thread starter maehe
  • Start date Start date
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
 
You can use the Trim function

Sub test()
For Each cell In Columns("A").SpecialCells(xlCellTypeConstants)
cell.Value = Trim(cell.Value)
Next
End Sub
 
Back
Top