ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   truncate text using VBA Excel (https://www.excelbanter.com/excel-programming/283225-truncate-text-using-vba-excel.html)

maehe

truncate text using VBA Excel
 

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

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com


Ron de Bruin

truncate text using VBA Excel
 
You can use the Trim function

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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"maehe" wrote in message ...

Hi,

I've got a progam running in CL (AS400) that exports a file into a csv
file. This file contains names of other files that I wish to open. The
problem being these fiels have a fixed length of 10 and are filled with
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 Emery


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/




maehe[_2_]

truncate text using VBA Excel
 

Thank You very much!

It's all implemented fine! Thank you again

:

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com