Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Fixed Length Text fields
Can anyone suggest how I can right pad a text field so that it always has a
fixed length of 18. I have an import requirement that a field is 18 characters long but the source data is variable length and unfortunately I cannot use delimiters in the import. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Fixed Length Text fields
Hi Mervin,
I have created a common function: Public Function RightPad(ByVal sOriginal As String, ByVal iLength As Integer) As String If Len(sOriginal) < iLength Then RightPad = sOriginal & Space(iLength - Len(sOriginal)) Else RightPad = Left(sOriginal, iLength) End If End Function It takes 2 parameters: 1) The string 2) The length it must have. If it is shorter some spaces will be added at the end. If if is to long it will be truncated at the given length. HTH. Executor |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Fixed Length Text fields
That's perfect!
Mervyn "Executor" wrote in message oups.com... Hi Mervin, I have created a common function: Public Function RightPad(ByVal sOriginal As String, ByVal iLength As Integer) As String If Len(sOriginal) < iLength Then RightPad = sOriginal & Space(iLength - Len(sOriginal)) Else RightPad = Left(sOriginal, iLength) End If End Function It takes 2 parameters: 1) The string 2) The length it must have. If it is shorter some spaces will be added at the end. If if is to long it will be truncated at the given length. HTH. Executor |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Text to column fixed length | Excel Discussion (Misc queries) | |||
Advanced export/ Fixed length fields | New Users to Excel | |||
Create fields in a form with a fixed length | Excel Discussion (Misc queries) | |||
save an excel file in fixed length records whose fields are blank | Excel Discussion (Misc queries) | |||
Save data in a worksheet in fixed length fields... | Excel Discussion (Misc queries) |