Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I export text from excel autoshapes to a text file? | Excel Discussion (Misc queries) | |||
Cell export to Text File? | Excel Discussion (Misc queries) | |||
export excel file as csv with text delimiter of " | Excel Discussion (Misc queries) | |||
Export excel file to semicolon delimited text file | Excel Discussion (Misc queries) | |||
Export to fixed width text file | Excel Discussion (Misc queries) |