![]() |
blank filling remaining characters in a field.
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. |
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. |
All times are GMT +1. The time now is 11:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com