blank filling remaining characters in a field.

G

Guest

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.
 
G

Guest

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
 

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