Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Modify macro code to export multiple cell contents to multiple Text Files

Hello,
I have 200 cells in column D with text in them. I want to use a macro
to generate 200 separate text files containing each individual cell
contents. If possible, I'd like to name of each text file to be based
on the cell adjacent in Column C. Using the macro below, I can generate
a text file from what ever cell I have highlighted. Since I'm not a
good macro writer, I'm not sure how to modify the code so it does what
I need. If someone could help me out I would be so grateful!!!

Sub Export()
Dim r As Range, c As Range
Dim sTemp As String

Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c

'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Modify macro code to export multiple cell contents to multiple Text Files

Your macro relies on you selecting a range, so if you click on the top
cell in column D you want to convert to a txt file and CRT-SHF- Down
Arrow and then run the macro it should work. To incorperate this into
the macro you need something like

Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select

Regards

Stopher

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Modify macro code to export multiple cell contents to multiple Text Files

Thank you for your quick reply. If I select multiple cells and run the
macro it creates on text file. I need to generate one text file for
each cell. I will need to generate approximately 200 text files for
the 200 cells I have in column D. The macro I included is the only
thing I could find that was close to what I am looking for. It's not
exactly what i'm looking for though because (a) it only generates 1
text file, and (b) it always generates the text file with the same name
at C:\MyOutput.txt. Thanks - T

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
export multiple sheets to multiple excel files Tanya Excel Discussion (Misc queries) 1 April 20th 09 08:57 PM
Import multiple text files (Macro) Thr33of4 Excel Discussion (Misc queries) 0 September 19th 06 02:19 AM
Getting multiple cell contents using a macro neilgrant Excel Programming 3 April 24th 06 10:25 PM
Open multiple text files and paste contents to single cell [email protected] Excel Programming 1 October 19th 05 04:05 PM
Loop thru multiple files - Modify worksheet visible property Mike Taylor Excel Programming 1 October 24th 03 04:03 AM


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"