Results 1 to 3 of 3

Thread: Macro to fetch csv files

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    24
    Rep Power
    0

    Macro to fetch csv files

    Hi Team,

    I need a macro which will get some values from user and on pressing a button i need csv files to be generated automatically. I need to generate some multiple csv files using this macro because we need to upload data in different tables.

    Kindly provide me suggestions on below things

    1.How to generate csv file from macro
    2.How to generate multiple files at a time.

    Regards
    Dhivya

  2. #2
    Member littleiitin's Avatar
    Join Date
    Aug 2011
    Posts
    90
    Rep Power
    13
    Below is the code for saving workbook as csv for Multiple saving you can use loop

    Code:
    Sub SaveasCSV()
        Dim strPath         As String
        Dim strFileName     As String
        
        strPath = "C:\Users\324954\Desktop\" ' Use your Path
        strFileName = "MyFile" ' Use your File Name
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=strPath & strFileName, _
            FileFormat:=xlCSV, CreateBackup:=False
        Application.DisplayAlerts = True
    End Sub

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    24
    Rep Power
    0
    Quote Originally Posted by littleiitin View Post
    Below is the code for saving workbook as csv for Multiple saving you can use loop

    Code:
    Sub SaveasCSV()
        Dim strPath         As String
        Dim strFileName     As String
        
        strPath = "C:\Users\324954\Desktop\" ' Use your Path
        strFileName = "MyFile" ' Use your File Name
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=strPath & strFileName, _
            FileFormat:=xlCSV, CreateBackup:=False
        Application.DisplayAlerts = True
    End Sub
    Hi littleiitin,

    Your code perfectly works. Thanks for that. But it replaces the name of my current workbook as sheet2.csv.. or i can say it closes my macro sheet.

    How to debug this. I guess something to do with the line below . Please help

    Code:
       ActiveWorkbook.SaveAs Filename:=strPath & strFileName, _

Similar Threads

  1. Macro To Close All CSV Files
    By Howardc in forum Excel Help
    Replies: 5
    Last Post: 03-15-2014, 05:24 PM
  2. Replies: 15
    Last Post: 08-23-2013, 12:03 PM
  3. export all worksheets to separate csv files
    By rabidfly in forum Excel Help
    Replies: 4
    Last Post: 11-18-2012, 02:11 PM
  4. Macro to export sheet as CSV
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 07-25-2012, 08:59 PM
  5. Collate Data from csv files to excel sheet
    By dhiraj.ch185 in forum Excel Help
    Replies: 16
    Last Post: 03-06-2012, 07:37 PM

Posting Permissions

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