+ Reply to Thread
Results 1 to 6 of 6

Create individual files from a row

  1. #1
    Registered User
    Join Date
    07-04-2005
    Posts
    2

    Create individual files from a row

    I have an excel file with several thousand entries, which contain data in several columns. I would like to be able to create an individual xml or html file for each row, but with predifined formatting around so

    Mr A bloggs, A street, A town, AA1 1AA

    Could become Abloggs.html

    <head></head>
    <name>Mr A bloggs</name>
    <street>A street</street>
    Any other info here as well
    </html>

    etc. Is this possible and any suggestions how?

    thanks,
    Graham.

  2. #2
    Fred
    Guest

    RE: Create individual files from a row

    Graham,

    How good is your HTML coding?

    You could write a macro to do exactly what you want.

    HTH

    "GrahamN" wrote:

    >
    > I have an excel file with several thousand entries, which contain data
    > in several columns. I would like to be able to create an individual
    > xml or html file for each row, but with predifined formatting around
    > so
    >
    > Mr A bloggs, A street, A town, AA1 1AA
    >
    > Could become Abloggs.html
    >
    > <head></head>
    > <name>Mr A bloggs</name>
    > <street>A street</street>
    > Any other info here as well
    > </html>
    >
    > etc. Is this possible and any suggestions how?
    >
    > thanks,
    > Graham.
    >
    >
    > --
    > GrahamN
    > ------------------------------------------------------------------------
    > GrahamN's Profile: http://www.excelforum.com/member.php...o&userid=24891
    > View this thread: http://www.excelforum.com/showthread...hreadid=384300
    >
    >


  3. #3
    Registered User
    Join Date
    07-04-2005
    Posts
    2
    I guessed a Macro may be the way, but this is an area I'm not too clued up on Anyone know any good resources?

  4. #4
    Dave Peterson
    Guest

    Re: Create individual files from a row

    I have no idea where the data is kept (different columns I hope???).

    But this may give you some ideas:

    Option Explicit
    Sub testme()

    Dim myFileName As String
    Dim FileNum As Long

    Dim myFolder As String

    Dim FirstRow As Long
    Dim LastRow As Long
    Dim iRow As Long

    'make sure it exists!
    myFolder = "C:\temp"
    If Right(myFolder, 1) <> "\" Then
    myFolder = myFolder & "\"
    End If

    With Worksheets("sheet1")
    FileNum = FreeFile
    FirstRow = 2 'headers in row 1??
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = FirstRow To LastRow

    Close FileNum
    myFileName = myFolder & "out" _
    & Format(iRow - FirstRow + 1, "0000") & ".txt"

    Open myFileName For Output As FileNum

    Print #FileNum, "<head></head>"
    Print #FileNum, "<name>" & .Cells(iRow, "A").Text & "</name>"
    Print #FileNum, "<street>" & .Cells(iRow, "b").Text & "</street>"
    Print #FileNum, "Any other info here as well"
    Print #FileNum, "</html>"

    Close FileNum

    Next iRow

    End With

    End Sub

    If you're new to macros, you may want to read David McRitchie's intro at:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    GrahamN wrote:
    >
    > I have an excel file with several thousand entries, which contain data
    > in several columns. I would like to be able to create an individual
    > xml or html file for each row, but with predifined formatting around
    > so
    >
    > Mr A bloggs, A street, A town, AA1 1AA
    >
    > Could become Abloggs.html
    >
    > <head></head>
    > <name>Mr A bloggs</name>
    > <street>A street</street>
    > Any other info here as well
    > </html>
    >
    > etc. Is this possible and any suggestions how?
    >
    > thanks,
    > Graham.
    >
    > --
    > GrahamN
    > ------------------------------------------------------------------------
    > GrahamN's Profile: http://www.excelforum.com/member.php...o&userid=24891
    > View this thread: http://www.excelforum.com/showthread...hreadid=384300


    --

    Dave Peterson

  5. #5
    Registered User
    Join Date
    07-13-2017
    Location
    Kuala Lumpur Malaysia
    MS-Off Ver
    13.0
    Posts
    2

    Re: Create individual files from a row

    Hi Dave,

    It seems that the VBA looks good, in addition I would like to have the contents in Column A as the name of extracted files.

    Many thanks

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Create individual files from a row

    Dhope888 welcome to the forum :0

    1st, there is no need to report a thread just becuase you want an answer :0

    2nd, Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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