Export csv separated by columns

0 votes

I want to export an Excel file with multiple sheets as a column-delimited CSV file.

The files are exported to CSV when I execute the code, but they are comma delimited rather than column delimited as I export in CSV.

Sub SaveShtsAsBook()
    Dim Sheet As Worksheet, SheetName$, MyFilePath$, N&
    MyFilePath$ = ActiveWorkbook.path & "\" & _
    Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
         '      End With
        On Error Resume Next '<< a folder exists
        MkDir (MyFilePath & "_csv") '<< create a folder
        For N = 1 To Sheets.Count
            Sheets(N).Activate
            SheetName = ActiveSheet.Name
            Cells.Copy
            Workbooks.Add (xlWBATWorksheet)
            With ActiveWorkbook
                With .ActiveSheet
                    .Paste
                    .Name = SheetName
                    [A1].Select
                End With
                 'save book in this folder
                .SaveAs ThisWorkbook.path & "\_csv\" & SheetName & ".csv", FileFormat:=xlCSV
                .Close SaveChanges:=True
            End With
            .CutCopyMode = False
        Next
    End With
    Sheet1.Activate
End Sub
Oct 15, 2022 in Others by Kithuzzz
• 38,000 points
408 views

1 answer to this question.

0 votes

Define FileFormat as xlText and the file will be TAB delimited, which you obviously are looking for.

f.ex.:

Private Sub CommandButton1_Click()
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    
    wb.SaveAs "c:\tmp\tabtest.csv", xlText
    
End Sub
answered Oct 15, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

Change the permission for a file created by me in linux

If you are the system administrator or ...READ MORE

answered Mar 8, 2019 in Others by Nabarupa
1,072 views
+2 votes
1 answer

How to compare 2 comna separated strings in informatica?

A java transformation can be used to ...READ MORE

answered Aug 18, 2019 in Others by Rojalin
• 200 points
1,460 views
0 votes
0 answers
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,212 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,663 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
908 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,053 views
0 votes
1 answer

Removing duplicates from Excel rows by adding values of some columns

Copy the first three columns to another ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,600 points
901 views
0 votes
1 answer

Excel: How to merge two columns into one (from different sheets or separated columns)

This equation is completely adjustable. Your two ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,600 points
864 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP