View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default blank filling remaining characters in a field.

One way is to define the fields with their specfied lengths and then assign
data as per example below. If data is longer than field, it is truncated.

Sub fixedFields()

Dim field As String * 8 ' length of 8

field = "ABC"
MsgBox Len(field) & " " & field
End Sub


HTH

"TTewell" wrote:

I have an Excel worksheet with 24 fields which I need to create a flat file
to be read by another application. I need to fill any unused spaces in a
field with spaces so that when I have a field defined as five characters in
length, but the data in the worksheet has variable length data. I need to pad
the rest with blanks. This ensures that that a certain field starts in a
required column and is a certain length long. example: Last_Name 53,20, the
last name field begins in column 53 and is 20 characters in length.