Results 1 to 4 of 4

Place results in separate columns when exporting to csv

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Cape Town
    MS-Off Ver
    Excel 2010
    Posts
    107

    Place results in separate columns when exporting to csv

    Hi,

    This is the code I am currently using. Problem is that the results are placed in a single column when the exporting to a CSV file. I tried adding the "," but doesn't seem to work.

    Sub ExtractResultSet()
        
        Dim DestFile As String
        Dim FileNum As Integer
        
         
         ' Prompt user for destination file name.
        DestFile = "c:/temp/test.csv"
         ' Obtain next free file handle number.
        FileNum = FreeFile()
         ' Turn error checking off.
        On Error Resume Next
         ' Attempt to open destination file for output.
        Open DestFile For Output As #FileNum
         
         ' If an error occurs report it and end.
        If Err <> 0 Then
            MsgBox "Cannot open filename " & DestFile
            End
        End If
         ' Turn error checking on.
        On Error GoTo 0
         
        ' Loop for each row in selection.
        For i = 1 To BaseData.NumberOfObservations
        
            ' Write current cell's text to file with quotation marks.
            Print #FileNum, i, ",", ModelResults.FittedMu(i), ModelResults.AIC, BaseData.xValue(1, i), BaseData.xValue(2, i), BaseData.xValue(2, i), ModelResults.FitResult
            
            
            
        Next i
         
         ' Close destination file.
        Close #FileNum
    
    End Sub
    Thanks in advance!
    Last edited by concatch; 11-15-2011 at 04:24 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1