+ Reply to Thread
Results 1 to 15 of 15

Save and close newly created CSV workbook

  1. #1
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Save and close newly created CSV workbook

    Hi,

    I have a macro that currently extracts data from a workbook and creates a new workbook, which i would then like to save and close this newly created workbook as a csv.

    I only need to set the save path once, so if i could include this path in the code, that would be great. I believe CSV's have pop ups when saving too with regards to saving and losing formatting etc, if they can be avoided to that would be great.

    The current code i have for the creation is

    Please Login or Register  to view this content.
    Hopefully that makes sense and any help would be much appreciated.

    Thanks in advance

    Marcosis

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Save and close newly created CSV workbook

    try this: strP is the path where you want the file saved.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by cubangt View Post
    try this: strP is the path where you want the file saved.

    Please Login or Register  to view this content.
    Hey,

    Thanks for responding. Where would that go? As good as the code looks that i put in my original post, i cant actually write code yet, so i take bits from this and that and hope everything works.

    Im slowly learning, but currently quite the amateur!

    Thanks again

  4. #4
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Save and close newly created CSV workbook

    put it between your save lines here:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by cubangt View Post
    put it between your save lines here:

    Please Login or Register  to view this content.
    Perfect! Ill test it out later and get back to you!


    Cheers

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Save and close newly created CSV workbook

    No need to make it too complex.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by jindon View Post
    No need to make it too complex.
    Please Login or Register  to view this content.
    Hey jindon,

    I know that that may have been simple for you, but i cant thank you enough! Thats perfect for what i need it for! Worked like a charm.

    I have one more request if possible, I want to call another macro after the one were currently talking about that saves a copy of the current workbook with the name being "Main sheet" (i cant type the real name as its a company thing) and then the value of J4.

    Ive tried using the below, but it ends with excel open with a blank area, no cells or worksheet, just empty and the main workbook closed. Its really strange. Is there another way?

    Thanks again

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Save and close newly created CSV workbook

    Not really sure about what you are trying to do...
    Perhaps
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by jindon View Post
    Not really sure about what you are trying to do...
    Perhaps
    Please Login or Register  to view this content.
    Hey,

    So i want the macro to do 2 things.

    The first is the CSV that you have sorted for me perfectly.

    The second would be saving a copy of the main original sheet with the filename being the the words "Main sheet " and then the value of J4 which is the PO Number.

    So you fill out all the details in the first, main sheet. You run the macro, it creates and saves the csv, then saves a copy of itself titled, for example, "Main Sheet 1234"

    Hopefully that makes more sense.

    Cheers

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by marcosis View Post
    The second would be saving a copy of the main original sheet with the filename being the the words "Main sheet " and then the value of J4 which is the PO Number.
    What is "main original sheet"?

  11. #11
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102

    Re: Save and close newly created CSV workbook

    Quote Originally Posted by jindon View Post
    What is "main original sheet"?
    Sorry the sheet that runs the macro.

    Its basically a blank Purchase order form, they fill out the PO order details, run the macro that will extra the data to the CSV, then save the Purchase order again as a seperate file excel file, with the filename of the PO, but with the PO number, written in J4 on the end of the file name, So "Purchase Order 123"

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Save and close newly created CSV workbook

    Is that "UploadSheetTemplate" or other sheet or workbook ?

  13. #13
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102
    Quote Originally Posted by jindon View Post
    Is that "UploadSheetTemplate" or other sheet or workbook ?
    UploadSheetTemplate is a sheet in the PO workbook which is hidden and pulls the data, just with a simple formula needed from the PO to the template and that’s what the CSV is actually made from.

    The reason I have that sheet hidden is because the CSV has to have specific headers, so it pulls the data and pastes it starting on row 2, so as to leave the headers alone.

    If that makes no sense haha, I’ll try and block out company details and send a copy.

    Let me know

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Save and close newly created CSV workbook

    I'm asking which worksheet do you want to save as a new workbook?
    Or is it a workbook itself, not a single worksheet, that the code is running from?

  15. #15
    Forum Contributor
    Join Date
    12-14-2017
    Location
    birmingham, england
    MS-Off Ver
    2016
    Posts
    102
    Quote Originally Posted by jindon View Post
    I'm asking which worksheet do you want to save as a new workbook?
    Or is it a workbook itself, not a single worksheet, that the code is running from?
    My bad.

    UploadSheetTemplate is the single worksheet from the workbook running the code that needs to be it’s own CSV workbook

+ 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] How To save entire book Within a newly created Folder
    By TBM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-23-2018, 10:33 AM
  2. [SOLVED] Run macro from newly created workbook
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2018, 08:54 AM
  3. bringing 2 sheets (at the end of workbook) to the Same newly created workbook
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2015, 07:10 AM
  4. [SOLVED] Save copy to newly created directory in the existing folder structure
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2015, 04:20 AM
  5. use existing creation date of workbook with newly created .saveas workbook
    By dwr0211 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2011, 12:42 PM
  6. Using a macro to add code to a newly created workbook.
    By Alagard in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-16-2010, 06:08 PM
  7. How to copy to newly created sheet and save as PDF?
    By joanneb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-30-2009, 04:05 PM

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