LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Excel to txt

I have a sheet set up with 2 columns of data (both numerical) and I am
using the code listed below to extract into a txt file, which works
fine.

0000000011000+00030+
0000000051000+00030+
8711000055380+00030+
8711000075371+00030+
8888021100013+00030+
etc etc etc

What I need to do is extract the data into a txt file which looks like

0000000011000+00030+0000000051000+00030+8711000055 380+00030+8711000075371+00030+
8888021100013+00030+ etc etc etc

I have not had experience before extracting from excel into a text file
and would appreciate some pointers.

Thanks,
Dean

Here is the code I have been testing (www.mcgimpsey.com)


Const DELIMITER As String = "+"
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String

nFileNum = FreeFile
Open "Test.txt" For Output As #nFileNum
For Each myRecord In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells(1), _
Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
End Sub

 
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



All times are GMT +1. The time now is 06:46 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"