+ Reply to Thread
Results 1 to 2 of 2

VBA to save/close and start new file on change of column A

  1. #1
    Forum Contributor
    Join Date
    12-18-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    108

    VBA to save/close and start new file on change of column A

    Hello all,

    I've run across a challenge whereby I'm 'wasting' time very day and I think it is something that I should be able to program in VBA.
    Unfortunately I have not yet been able to find out how, so here comes my request to you.

    I need the source data to be copied over from by source file to an external file per unique order number, email that external file, and then start with the next order number, and cycle through the document until all orders are done.

    source document = "data.xlsx"
    external document = "template 1.xlsx"

    1. Column A of the source document contains the order number (this could be 1 lines, but could also be 10 lines with the same order reference number)
    2. Data from column B-C (basically the content of each order) of that source document needs to be copied over to cell A1 external document. (let call this "template 1.xlsx").
    The number of lines to be copied over from B-C is equal to the amount of lines that have the same order reference as column A
    3. After data is copied over, "template 1.xlsx" is to be saved with the order reference number from Column A
    4. VBA needs to send an email to "[email protected]"
    5. Identify if there is a new unique number in column A, if so, continue steps 1-4 until all unique references are completed. If no, stop VBA

    How can i get VBA to recognize the 'unique' reference number and copy over the appropriate columns, and then start with the next unique line?
    I have attached the sample files and hopefully, with your assistance, I can get this automated.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA to save/close and start new file on change of column A

    Something like this should work

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

+ 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. Replies: 8
    Last Post: 12-02-2019, 03:42 PM
  2. Ignore that the file is already is open, or close it to start with.
    By Dkstaurs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-12-2014, 09:14 AM
  3. Problem With Open File and Save File With Saveas and then close the File
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 12:53 AM
  4. Replies: 1
    Last Post: 10-25-2013, 06:10 PM
  5. Replies: 1
    Last Post: 10-01-2012, 11:46 PM
  6. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM
  7. Replies: 0
    Last Post: 08-30-2006, 05:58 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