+ Reply to Thread
Results 1 to 6 of 6

VBA Macro to export cells to text file and add extra spaces

  1. #1
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108

    VBA Macro to export cells to text file and add extra spaces

    Hello,

    Is there a way to export cells to a text file, but specify the width of each exported cell? Specifically, say I want it to export 50 characters, and if the cell value only has 20, fill the last 30 with spaces...then do that for every cell I specify, for row 2 and beyond.

    Is there an easy way to do that?

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA Macro to export cells to text file and add extra spaces

    can you attach a sample xls file and desired text file ?
    If solved remember to mark Thread as solved

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Macro to export cells to text file and add extra spaces

    Please Login or Register  to view this content.
    You will need to change paths, ranges etc as neccessary.

  4. #4
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108

    Re: VBA Macro to export cells to text file and add extra spaces

    Thank you for the reply, let me try that out.

  5. #5
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108

    Re: VBA Macro to export cells to text file and add extra spaces

    I got an error when running it:

    "Runtime error 438. Object doesn't support this property or method"

    Debug pointed to this line:

    Set fil = fs.createtextfil("C:\Test.txt")

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Macro to export cells to text file and add extra spaces

    sorry, typo. Should be createtextfile not createtextfil. Also change the path if you need to.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to remove extra spaces in an Excel File
    By Ardiko in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2013, 10:33 AM
  2. removing extra spaces inside of cell of text
    By Ajax Matt in forum Excel General
    Replies: 2
    Last Post: 07-27-2011, 05:56 PM
  3. [SOLVED] eliminating extra spaces in Excel cells
    By Laura1 in forum Excel General
    Replies: 4
    Last Post: 03-17-2006, 01:35 PM
  4. Eliminating extra spaces within cells
    By j3nnifers in forum Excel General
    Replies: 4
    Last Post: 03-17-2005, 05:17 AM
  5. printing extra spaces? breaking text
    By rickjes in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 02-01-2005, 04:30 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1