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: 1
Default Need Help With Export Code


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
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
VBA Code to Export Data from Chart Curt J Excel Discussion (Misc queries) 4 April 7th 10 10:35 PM
Import VBA Code in Excel-File ? (Export VBA Code to file) Matthias Pospiech Excel Programming 2 March 22nd 05 04:56 PM
Improve ADO code, Export Excel to Access SteveC Excel Programming 1 August 5th 04 10:33 AM
Request Vba code Export gif file Luigi[_2_] Excel Programming 3 February 17th 04 12:52 PM
Export a form via code? [email protected] Excel Programming 4 January 26th 04 04:22 AM


All times are GMT +1. The time now is 12:02 AM.

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"