Export Part Of Spreadsheet As .csv File

  • Do you need to export part of a spreadsheet (in this example, A3:A5) into an external, yet uncreated spreadsheet, saved as a special file type (.csv in the example)?


    My pain is your gain.


  • Re: Export Part Of Spreadsheet As .csv File


    This takes me back, wow. I'm a bit rusty with VBA code but my guess would be to have a cell in spreadsheet showing current date & time, and the code referring to that cell for the filename. The how part would need someone with fresh VBA thinking.

  • Re: Export Part Of Spreadsheet As .csv File


    Hi, I had to do something similar, and used the above for guidance. I've now completed the code, and decided to share it. Hope the comments make it understandable.
    I've put a command button on the sheet, and connected it to the macro, though you could just run the macro directly.
    I select a range, then press the button. The selected range is then copied to a csv file, and then opened in Notepad for onward selection into another application.
    I made a slight addition to help mkrprasad get started with the date in the file name.





    Regards



    Rich

  • Re: Export Part Of Spreadsheet As .csv File


    Quote from Elmura;590112

    Code looks good. Haven't tested it, and am a bit rusty.


    Note that I recall the Shell command being unreliable


    I've found the Shell command OK, especially for doing something simple like opening notepad. I believe the shell command is less reliable when used in a batch file to run another batch file.


    Try creating a new spreadsheet, populating it with a range of random numbers, and copying the code as is into the VB macro area.
    Select a range of cells, and run the macro and ... Bingo! :)


    Rich