+ Reply to Thread
Results 1 to 3 of 3

Export into multiple text files depending on a condition

  1. #1
    Registered User
    Join Date
    05-26-2021
    Location
    Ecu
    MS-Off Ver
    2019
    Posts
    2

    Export into multiple text files depending on a condition

    Hi.. need help here, I'm fairly new in VBA coding I've been searching the forum but i can't find similar case..

    I need to generate multiple notepad files from an excel file..

    Each text file has to be exported when it belongs to the same file name in column A, that is, column B will be part of the text file in column A namefile. it is somewhat confusing to explain; is something like this

    COLUMN A COLUMN B
    1 -FIL_NAME Information
    V210201003 LINEA1
    V210201003 LINEA2
    V210201003 LINEA3
    V210201003 LINEA4
    V210201009 LINEA1
    V210201009 LINEA2
    V210201009 LINEA3
    V210201010 LINEA1
    V210201010 LINEA2
    V210201011 LINEA1


    Tetx file V210201003 will contains the information of column B

    Text File V210201003
    LINEA1
    LINEA2
    LINEA3
    LINEA4

    Text File V210201009
    LINEA1
    LINEA2
    LINEA3


    Text File V210201010
    LINEA1
    LINEA2




    And the file name is based on the column A..

    Could anyone help me?
    I'd appreciate any help
    thanks.
    Attached Images Attached Images
    Attached Files Attached Files

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

    Cool Hi ! Try this !


    According to your attachment a VBA demonstration as a beginner starter :

    PHP Code: 
    Sub Demo1()
      Const 
    " .txt"
        
    Dim F%, P$, VR&, S$
            
    FreeFile
            P 
    ThisWorkbook.Path "\"
            V = Hoja1.[A1].CurrentRegion.Columns("
    A:B").Value2
        For R = 2 To UBound(V)
            If V(R, 1) <> S Then S = V(R, 1): Close #F: Open P & S & E For Output As #F
            Print #F, V(R, 2)
        Next
            Close #F
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Registered User
    Join Date
    05-26-2021
    Location
    Ecu
    MS-Off Ver
    2019
    Posts
    2

    Re: Export into multiple text files depending on a condition

    Yeah, it works!!!.

    Thanks for your time. i'll try to learn about this.

    Thanks in advance.

+ 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] IF function. How to substitute depending on condition in another text box
    By Al_Excel in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2017, 11:31 AM
  2. split text files stored in some location to multiple files based on a condition
    By GIRISH_KH in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2013, 11:32 AM
  3. [SOLVED] Change color of text depending on condition using vba
    By jacob@thepenpoint in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2012, 09:08 AM
  4. Split data from one excel spreadsheet and export to multiple text files
    By jmsavage in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2012, 05:30 AM
  5. Excel VBA row export to multiple text files
    By warren13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2011, 03:02 AM
  6. Export multiple columns to single column text files including special characters
    By mike4uuu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2011, 04:54 AM
  7. how to export Unicode data to multiple text files
    By world33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2010, 12:44 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1