Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi. Below is some code I wish to use to export a "modified" csv file. By "modified" I mean that the csv file uses a semicolon ; as the seperator and not a comma. I have found that Excel sometimes misreads csv files which use commas; especially when original cell entries have dashes in them (such as 1-5, 3-8 . . . these are output incorrectly as dates Jan-05, Mar-08, etc.) The code below overcomes any of Excel's misreading issues, placing a semicolon as a spacer between fields. My request is to find a compliment to this code. That is, what VBA code could import such a "modified" csv file into a specified range in Excel ? (Without any semicolons being imported into the Excel cells). Example: if the ExportModifiedCSV code used January.xls, Sheet 1, range A18:AG142, and my desired input range is February.xls, Sheet 2, range B18:AH142. What code would do this -- stripping out any semicolons ? Below is the exporting code. I truly appreciate your help. WayneK Sub ExportModifiedCSVFile() Dim FName As String Dim fs As Object Dim ftext As Object Dim wf As WorksheetFunction Dim x Dim i As Long Application.ScreenUpdating = False Set wf = WorksheetFunction FName = ThisWorkbook.Path & "\" & "Temp1.csv" Set fs = CreateObject("Scripting.FileSystemObject") Set ftext = fs.CreateTextFile(FName, True, 0) 'workbook January.xls is already open, with Sheet 1 active With Range("A18:AG142") For i = 1 To .Rows.Count x = Join(wf.Transpose(wf.Transpose(.Rows(i))), "; ") ftext.WriteLine x Next i End With ftext.Close Set fs = Nothing Set ftext = Nothing Application.ScreenUpdating = True End Sub -- WayneK ------------------------------------------------------------------------ WayneK's Profile: http://www.excelforum.com/member.php...o&userid=23037 View this thread: http://www.excelforum.com/showthread...hreadid=382986 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA Code to Export Data from Chart | Excel Discussion (Misc queries) | |||
Import VBA Code in Excel-File ? (Export VBA Code to file) | Excel Programming | |||
Improve ADO code, Export Excel to Access | Excel Programming | |||
Request Vba code Export gif file | Excel Programming | |||
Export a form via code? | Excel Programming |