+ Reply to Thread
Results 1 to 10 of 10

Exporting part of a worksheet to text file using VBA

  1. #1
    Registered User
    Join Date
    03-09-2012
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    61

    Exporting part of a worksheet to text file using VBA

    Hi,

    I'm looking for a way to write only part of a worksheet (cells A10:E150, for example) to a text file.

    Any idea?

    Thanks

    Mike

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Exporting part of a worksheet to text file using VBA

    Select the cells and run the first macro - you can certainly modify this to make it less instrusive....

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Exporting part of a worksheet to text file using VBA

    Here's a slightly different approach - I recently had to write some text files in UTF-8 format, and found this method the best:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Exporting part of a worksheet to text file using VBA

    My contribution.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Exporting part of a worksheet to text file using VBA

    I like that - but you could change

    Please Login or Register  to view this content.
    to just

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Exporting part of a worksheet to text file using VBA

    Yes, nice spot, thanks!

  7. #7
    Registered User
    Join Date
    03-09-2012
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Exporting part of a worksheet to text file using VBA

    Hi, thanks for all the responses!

    Quick question, some of the cells I'm exporting are blanks, does anyone know how I could replace blanks with quotation marks?

    Thanks again, much appreciated!

    Mike

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Exporting part of a worksheet to text file using VBA

    To display blanks as quotation marks, we can add in a few lines:

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Exporting part of a worksheet to text file using VBA

    Maybe this too...

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    03-09-2012
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Exporting part of a worksheet to text file using VBA

    Great, thanks managed to get it working! Awesome!

    Thanks again to everyone!

    Mike

+ 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. Exporting Excel into CSV text file
    By pinoydarv in forum Excel General
    Replies: 2
    Last Post: 03-30-2010, 10:45 AM
  2. Exporting Figures from a Worksheet to a File
    By echiesse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2009, 08:36 AM
  3. Exporting one column to text file
    By Brelin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-21-2008, 12:29 AM
  4. HELP!! Exporting formatted text file
    By Excel user via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2005, 11:05 AM
  5. [SOLVED] Exporting from Excel to a text file
    By Josh Brien in forum Excel General
    Replies: 3
    Last Post: 05-20-2005, 05:06 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1