+ Reply to Thread
Results 1 to 5 of 5

Macro to Sort a table and Save file as a CSV

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Lightbulb Macro to Sort a table and Save file as a CSV

    I have a macro that manupulates data into a table. I need to cut and paste this table into a new worksheet, sort by "ticket" and save into a CSV file. See attached Table starts at line 101. Please help
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-09-2012
    Location
    Anch, Alaska
    MS-Off Ver
    2003, 2010, 2013
    Posts
    131

    Re: Macro to Sort a table and Save file as a CSV

    The code is assuming that the Data will always start on Row 101, if not changes will have to be made.
    The Export function will export the file "Exported CSV File.csv" to your C:\ Drive, the file-name and location can be changed if you choose to do so.

    Give it a try. Excel Sort and Save RevA.xlsm

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Macro to Sort a table and Save file as a CSV

    BuckoAK, thanks this helps out a lot. However, the table location will change depending how many ACCTs there are in the data field (it will not always start at "101"). I tried implementing this code in the code you created to reference the differing location of the table but I get "Range of Object failed" response. I can't seem to figure out why this is happening?

    Please Login or Register  to view this content.
    Here is my code to create the table.

    Please Login or Register  to view this content.
    Thanks for your help!!
    Last edited by Cutter; 09-04-2012 at 11:40 AM. Reason: Added code tags

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro to Sort a table and Save file as a CSV

    @ dirock

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  5. #5
    Forum Contributor
    Join Date
    08-09-2012
    Location
    Anch, Alaska
    MS-Off Ver
    2003, 2010, 2013
    Posts
    131

    Re: Macro to Sort a table and Save file as a CSV

    Here you go, this is a fully working macro.

    I add a variable in your code, to pass along to the new code.
    This line identifies a dynamic starting position each time.

    Give it a run and let me know what you think.
    Attached Files Attached Files
    Give Credit When Credit Is Due - Click On the Star
    Be Sure To Mark Your Post [Solved] When You Get Your Answer

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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