read a spreadsheet and save each row as a txt file

dbzmkl

New Member
Joined
Jul 9, 2011
Messages
10
I have a problem that i don't know if is solvable.
i have a spreadsheet with information regarding about 1000 pictures i.e. picture id, name, number, date, place taken.
here is a sample csv

picture id,name,number,date,place taken
DRN1000,Quynn X. Black,MZY57RRN7JF,1/31/2012 11:39,Downey
DRN1001,Allegra T. Jackson,QPF47BKJ5AB,6/19/2012 15:06,West Jordan
DRN1002,Mollie A. Sims,PIA58UFO3ZX,4/11/2011 14:20,Marietta
DRN1003,Connor A. Wall,YPP10JFL7TL,11/20/2010 15:41,Santa Barbara
DRN1004,Nissim Q. Burch,TSZ72VNL3WL,10/23/2011 2:39,Fairfax


i need to separate this info according to rows and save as a text file
but the catch is the new file created should have the following format

type=dd:PicturesContentType
dd\:name=Quynn X. Black
dd\:number=MZY57RRN7JF
dd\:date=1/31/2012 11:39
dd\:place taken=Downey


and the name of each new file should be what is in the first row i.e the above file will be named DRN1000.

any help will be highly appriciated.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi

This should work for you?

Code:
Sub MakeTXT()
Dim LastRow As Long, i As Long

LastRow = Range("A65536").End(xlUp).Row

For i = 2 To LastRow

    Open Cells(i, "A").Value & ".txt" For Output As #1
    
        Print #1, "type=dd:PicturesContentType"
        Print #1, "dd\:name=" & Cells(i, "B").Value
        Print #1, "dd\:number=" & Cells(i, "C").Value
        Print #1, "dd\:date=" & Cells(i, "D").Value
        Print #1, "dd\:place taken=" & Cells(i, "E").Value
        
    Close #1
     
Next i

End Sub
HTH :)
 
Upvote 0
this is by far the most amazing code i've seen, i love the simplicity
thanks for pointing me to the right direction
 
Upvote 0

Forum statistics

Threads
1,224,588
Messages
6,179,743
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top