+ Reply to Thread
Results 1 to 16 of 16

vba writeline method

  1. #1
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    vba writeline method

    hi everyone- I wanted to reach out and see if anyone has experience using the writeline method on Excel VBA.

    this is what I am trying to accomplish: writeline ('input text here,' 'insert Excel range', 'insert end text') all to write to a text file.

    thanks in advance

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    No, not as such. I've used other methods to write to text files.

    However, see: https://docs.microsoft.com/en-us/off...tstream-object
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Hi !

    Quote Originally Posted by hgchas View Post
    if anyone has experience using the writeline method on Excel VBA.
    Yes but as it depends on your source data worksheet and the expected text file result
    and after all as we are not on a mind readers forum …

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: vba writeline method

    If you want to write the values from range of multiple cells to a text file then you are going to have to do some work with those values.

    For example, do you want to concatenate them with a delimiter?

    List each value on it's own line?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    Re: vba writeline method

    hi everyone, thanks for the response.

    this is the code I am working with

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: vba writeline method

    That doesn't really tell us how you want to write the values from the range to the file.

  7. #7
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    Re: vba writeline method

    writeline ('input text here,' 'insert Excel range', 'insert end text') 'this is the area I want to utilize

    I want to have the code write out the line with the range, something like this: "These are the values I want to show you all, Range(A1:A). Let me know if you have questions."

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: vba writeline method

    How would you want the values in the range to appear in the text file?

  9. #9
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    Re: vba writeline method

    Hi- I would like for the values in Range (A1:A) to appear embedded in between the two texts.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    Try

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    Re: vba writeline method

    It did not function stating it was a mismatch error.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    Please Login or Register  to view this content.

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    For completeness ...

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    06-05-2019
    Location
    texas
    MS-Off Ver
    2013
    Posts
    53

    Re: vba writeline method

    Thank you! This seemed to work

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    You're welcome.

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,421

    Re: vba writeline method

    Please keep all questions in the thread. For the benefit of others, do not PM contributors or solution providers.

    hello-I'm sorry to bother, I had a quick question on an error I am getting.

    IT IS HERE, I AM TRYING TO ADD " " TO SURROUND THE RANGE WHEN IT GENERATES THE TXT FILE-LIKE THIS "RANGE(A1:A10)"= "123," "345," "567," ETC.

    This seems to do what you want. You may need to tweak which spaces to include or leave out.

    Please Login or Register  to view this content.
    The output looks like this:

    HTML Code: 

+ 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. Feedback Appreciated: VBA Coding Method: Simple Number to Words using SLST Method
    By MohsenAlyafei in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2019, 05:42 AM
  2. Replies: 2
    Last Post: 09-25-2012, 12:53 AM
  3. A More Efficient Method Than the Evaluate Method?
    By anthony.mcgovern in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-22-2011, 05:39 AM
  4. Returning the number of cells from one method to another method.
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-08-2010, 11:28 AM
  5. Replies: 3
    Last Post: 05-11-2007, 09:38 AM
  6. GetObject method not work after Call Shell Method
    By ben in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2006, 11:50 AM
  7. Why QUIT method doesn't work after COPY method?
    By surotkin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2005, 11:32 AM

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