Results 1 to 3 of 3

Thread: How to create fixed lengh cell and rows in Microsoft Excel

  1. #1
    Join Date
    Feb 2012
    Posts
    13

    How to create fixed lengh cell and rows in Microsoft Excel

    Need fixed length cells and rows in excel spreadsheet saved as space delimited .prn file. The .prn file will be FTP'd to Mainframe computer file (which has fixed length fields (each cell = a field in Mfrm file) in a fixed length record. Is there a way to format cells as text data, with a fixed number of spaces in the cell. Then the client could overtype the spaces with the required data.

  2. #2
    Join Date
    Nov 2010
    Posts
    422

    Re: How to create fixed lengh cell and rows in Microsoft Excel

    The output file won't be space delimited--it'll be fixed width. There's a limit of 240 characters per line when you save as .prn files. So if your data wouldn't create a record that was longer than 240 characters, you can save the file as .prn. I like to use a fixed width font (courier new) and adjust the column widths manually. But this can take a while to get it perfect. (Save it, check the output in a text editor, back to excel, adjust, save, and recheck in that text editor. Lather, rinse, and repeat!). Alternatively, you could concatenate the cell values into another column: =LEFT(A1&REPT(" ",5),5) & LEFT(B1&REPT(" ",4),4) & TEXT(C1,"000,000.00"). (You'll have to modify it to match what you want.). Drag it down the column to get all that fixed width stuff. Then I'd copy and paste to notepad and save from there. Once I figured out that ugly formula, I kept it and just unhide that column when I wanted to export the data. If that doesn't work for you, maybe you could do it with a macro.

  3. #3
    Join Date
    Nov 2010
    Posts
    503

    Re: How to create fixed lengh cell and rows in Microsoft Excel

    There is a macro for columns. You can try the below code and then check back.
    Code:
     Sub colonnesEnCentimetres () 
     Sun cm As Integer, points As Integer, savewidth As Integer 
     Sun count As Integer 
     Application.ScreenUpdating = False 
     Application.InputBox cm = ("enter the column width in cms"  "The desired column width", Type: = 1) 
     If cm = False Then Exit Sub 
     = Application.CentimetersToPoints points (cm) 
     savewidth = ActiveCell.ColumnWidth 
     = 255 ActiveCell.ColumnWidth 
     If points> Then ActiveCell.Width 
     MsgBox "width" & cm & "is too broad" & Chr (10) & _ 
     "The maximum value is" & _ 
     Format (ActiveCell.Width / 28.3464566929134, _ "0.00"), vbOKOnly + vbExclamation, "Invalid width" 
     ActiveCell.ColumnWidth = savewidth 
     Exit Sub 
     End If 
     lowerwidth = 0 
     = 255 upwidth 
     ActiveCell.ColumnWidth = 127.5 
     curwidth = ActiveCell.ColumnWidth 
     count = 0 
     While (ActiveCell.Width <> points) And (count <20) 
     If ActiveCell.Width <points Then 
     lowerwidth = curwidth 
     Selection.ColumnWidth = (+ curwidth upwidth) / 2 
     Else 
     upwidth = curwidth 
     Selection.ColumnWidth = (+ curwidth lowerwidth) / 2 
     End If 
     curwidth = ActiveCell.ColumnWidth 
     count = count + 1 
     Wend 
     End Sub

Similar Threads

  1. Want help to create roll up rows in Microsoft Excel
    By Ambition in forum MS Office Support
    Replies: 2
    Last Post: 24-02-2012, 07:21 PM
  2. Replies: 2
    Last Post: 23-02-2012, 07:23 PM
  3. Replies: 2
    Last Post: 18-01-2012, 06:55 PM
  4. VBA to hide the rows in Microsoft Excel
    By Lanka Boy in forum MS Office Support
    Replies: 1
    Last Post: 14-01-2012, 03:12 PM
  5. Replies: 6
    Last Post: 23-07-2011, 01:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,077,857.65160 seconds with 17 queries