+ Reply to Thread
Results 1 to 13 of 13

Moderation of macro for export to csv file

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Moderation of macro for export to csv file

    Hi I have below code which for the first give me an error and for the second, would really need it to be changed so it start from row 3.
    It has columns from A to AQ, The out put for the empty ones should just be comma ,,. Also if possible I would like to have a file prompt, so I can choose where to save the file. Please have a look and also check the test file.

    Thanks in advance
    Abjac
    PS. Use excel 2003


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: Moderation of macro for export to csv file


    Hi,

    just put "3" to start rows loop
    and use GetSaveAsFilename method (read inner VBA help) for the file prompt …

    Beginner lever, you can do it !
    Last edited by Marc L; 07-29-2014 at 09:21 AM.

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    Hi Marc I think I have a clou where to put the 3 in, but I cant test it there is an error also in the macro I cant find out of.
    And the GetSaveAsFilename method I really have doubt how to do this. It shall be that it save ever row in one line with comma between

    Please have a look, cant get rid of the error. Its a object defined error,

    Thanks

    Sincerely
    Abjac

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Moderation of macro for export to csv file


    Which error ? Code runs fine without any issue !

    Edit : 'cause of using ActiveCell in code, cell A2 must be active …
    Last edited by Marc L; 07-29-2014 at 12:07 PM.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    HI Marc.
    This one is at least working so if I mark A3 it take the right ones and separate with comma. I need instead of the selected cell to have a common range in all rows which have input and still the save file dialog.

    I know I have to put this in but after many tries I cant make it work.

    Please Login or Register  to view this content.
    the code as is is now

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool See this crap !

    Please Login or Register  to view this content.
    Following your idea, this code works well but it's crappy !
    Just an average grade, maybe 12/20 … Why ?

    'Cause first, Copy / Paste is not coding !
    And read inner VBA help is not a waste of time !

    If you had read for example Print # help, you'd see another statement
    that do not need any conversion for double quotes neither comma insertion ‼

    All is written black on white in the book (inner VBA help) !

    Respecting TBTO rule, code needs only 3 variables :
    one for the output file number, one for the rows loop,
    one for the columns loop and that's all folk !

    Don't forget With statement !

    By following GetSaveAsFilename help - very beginner level - one more variable for the file
    and thus reaching a 20/20 grade …
    Last edited by Marc L; 07-29-2014 at 01:57 PM.

  7. #7
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    Thanks Marc for moderate the code. Sorry its crappy don't say I am expert but I guess its working which for me is progress, just wish I could get the GetSaveAsFilename in there too. But thanks allot

    Sincerely

    Abjac

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: Moderation of macro for export to csv file


    Reading is not deserved to experts ‼

    If you don't success to read & apply a very, very, very, and so on …,
    very beginner level help, better is to stop coding !

    Code to paste in worksheet module :
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    Hi Marc and thanks your code work brilliant. I have one question. If I want the code only separate with comma and not semicolon, how will it look then?

    Thanks

    Abjac

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Moderation of macro for export to csv file


    I don't understand 'cause according to the Write # help, separator is comma …


    Edit :

    I understand but if you had ever read this help and open the generated output file,
    you wouldn't post this useless question !
    Last edited by Marc L; 07-29-2014 at 06:44 PM.

  11. #11
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    I don't think this is useless question and I guess its here you can ask these questions right?
    The output should look like this

    706,02,738154,01,,,000020265655 ,,,,Y,S,COR,,FR7630003031750002026565564,738154,311213,,ALL,,,,,,,,,,,,,,,,,,,,,,,,

    But it looks like this

    706,"02","738154","01","","","000020265655 ","","","","Y","S","COR","","FR7630003031750002026565564","738154","311213","","ALL","","","","","","","","","","","","","","","","","","","","","","","",""

    I just wanted to get off the "" and only have the , as separator.
    Its ok if you think its a useless question, but I guess its here in a help forum, you can ask all questions.

    Thanks
    Abjac

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Moderation of macro for export to csv file


    Useless as written in VBA inner help …

    You never mention since your original post you don't need double quotes ‼
    So why use them in your original code ?‼

    Never mind, forget my codes but now you have enough data to moderate yourself from your original code …

  13. #13
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Moderation of macro for export to csv file

    Thanks Marc. Your codes are brilliant. So its a big help.I took the double quotes of when I saw the layout I need to input in other application. That's why it was not in the original code. But correct I can make it now.

    So thanks for you help.

    Sincerely
    Abjac

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to export tab to csv file issue
    By thaykhov in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2014, 05:25 AM
  2. help with making macro for export xls file to xml
    By mareza in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2014, 03:57 PM
  3. Macro to export from one excel file to another
    By SKaplan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-10-2011, 04:56 AM
  4. Set up Macro to export as CSV file
    By bconner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2011, 12:55 PM
  5. Macro to export file (HELP!!)
    By greenfalcon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2005, 05:02 AM

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