LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Export range to text file

I have this code that I use to create a csv for later update some values in a
system I hope it works

Dim ColId As Integer
Dim ColIn As Integer
Dim ColDur As Integer
Dim Colseg As Integer

Sub Initialize()
ColId = 1
ColIn = 2
ColDur = 3
Colseg = 4
End Sub

Sub MakeFile()
Dim CVSFile As String
Dim NumFile As Integer
Dim Fecha As Date
Dim Reng As Long
Dim Cadena As String
Initialize
NumFile = FreeFile
Open ActiveWorkbook.Path & "\Myfile.txt" For Output As #NumFile
Reng = 2
While Trim(ThisWorkbook.Worksheets(1).Cells(Reng, ColId).Value) < ""
Cadena = CreateString(Reng)
Print #NumFile, Cadena
Reng = Reng + 1
Wend
Cadena = ""
Print #NumFile, Cadena
Close #NumFile
End Sub

Function CreateString(R As Long) As String
Dim Cad As String
Cad = "00,"
Cad = Cad & Trim(Trim(ThisWorkbook.Worksheets(1).Cells(R, ColId).Value))
& "," 'COLID
Cad = Cad & Trim(Trim(ThisWorkbook.Worksheets(1).Cells(R,
Colseg).Value)) & "," 'dURATION
Cad = Cad & Format(ThisWorkbook.Worksheets(1).Cells(R, ColIn).Value,
"hh:mm") & ","
Cad = Cad & Format(ThisWorkbook.Worksheets(1).Cells(R, ColDur).Value,
"hh:mm") & ","
CreaLATE = Cad
End Function


Regards.....

elMedex

"Matthew Scheperle" wrote:

I need to export a range from excel to a text file with a delimiter such as a
comma or semicolon. I want to be able to have some kind of macro that will
check each row and if a row is blank then it will stop there and only export
the rows that has data. Which is why I was thinking of using a range, or
array.

I do have some formulas in the cells so do not want that to show up in the
export.

Thanks,
--
Matt Scheperle


 
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 can I export text from excel autoshapes to a text file? Donncha Excel Discussion (Misc queries) 0 July 20th 06 04:58 PM
Cell export to Text File? Steve Excel Discussion (Misc queries) 3 December 7th 05 03:13 PM
export excel file as csv with text delimiter of " John Excel Discussion (Misc queries) 2 May 12th 05 05:50 PM
Export excel file to semicolon delimited text file capitan Excel Discussion (Misc queries) 5 April 7th 05 03:06 AM
Export to fixed width text file FinChase Excel Discussion (Misc queries) 0 January 24th 05 07:25 PM


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