LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to create many txt files from a Excel file ?

Here is a example that Dave Peterson posted a few months back
It save the files in your temp folder (StartRun %temp% )

With your data in a sheet named "Sheet1" and data in the A column


Sub testme()
Dim wks As Worksheet
Dim newWks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim myStep As Long
Dim iCtr As Long

myStep = 12

Set wks = Worksheets("sheet1")
Set newWks = Workbooks.Add(1).Worksheets(1)
iCtr = 0
With wks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iRow = FirstRow To LastRow Step myStep
newWks.Cells.Clear
.Rows(iRow).Resize(myStep).Copy _
Destination:=newWks.Range("a1")
With newWks
Application.DisplayAlerts = False
iCtr = iCtr + 1
.Parent.SaveAs Filename:=Environ("temp") & "\Extracted_" _
& Format(iCtr, "000"), _
FileFormat:=xlCSV
Application.DisplayAlerts = True
End With
Next iRow
End With

newWks.Parent.Close savechanges:=False
End Sub

--
Regards Ron De Bruin
http://www.rondebruin.nl



"demianill" wrote in message
...

Hi all !

I'm not a programmer, just a simple Excel user.
I have the following problem:


- I have a Excel file with more than 11,000 lines.
- I need to read the first 12 lines (line 1 to line 12) and create a
txt file (the filename could be "1.txt", for example)
- Then, read the next 12 lines (line 13 to line 24) e create the
filename "2.txt"
- Again, again, and again, for each next 12 lines, until the end of
11,000 lines, creating the filename "916.txt".


Probably, it's very easy for expert users, using a VBA macro.
But, for non-programmers, it's a big problem !

Please, help me ! Thanks for all !!!


Demian Nill


--
demianill
------------------------------------------------------------------------
demianill's Profile: http://www.excelforum.com/member.php...o&userid=25676
View this thread: http://www.excelforum.com/showthread...hreadid=553386



 
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
How do I create and save .odc and .oqy files in excel? Ravindra Joshi Excel Discussion (Misc queries) 0 September 16th 06 06:06 AM
Create new excel files, Save backup of excel file Gil[_4_] Excel Programming 8 May 9th 06 09:40 PM
create a inventory of files on computer in excel Shanerrs Excel Discussion (Misc queries) 1 April 27th 05 04:07 PM
How to I create a pdf file from Word or Excel files stolitx Excel Discussion (Misc queries) 4 December 28th 04 07:17 PM
Why does Excel in XP create new files? Lindy Excel Discussion (Misc queries) 3 December 2nd 04 12:56 AM


All times are GMT +1. The time now is 11:58 PM.

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

About Us

"It's about Microsoft Excel"