+ Reply to Thread
Results 1 to 8 of 8

VBA open file, insert data, close file by tab.

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    55

    VBA open file, insert data, close file by tab.

    Hello All,
    Im trying to get VBA to open a file based on the name of a tab. Such as tab "Cabbage Cp" would open file Cabbage 2013, insert the data into the tab called "Cabbage CP", save file and close. I have to do this for multiple products on a weekly/monthly basis. It takes hours and sometimes a couple days. I figured with it being so simple, it can be automated. An help is greatly appreciated.
    Attached Files Attached Files
    Last edited by Aquabat; 12-26-2013 at 02:03 PM.

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA open file, insert data, close file by tab.

    Hi,

    1. In your sample you have more than one "Cabbage" which would be the key word to open the file. So if "Cabbage CP" opens "Cabbage 2013" what does "Cabbage SA" open?
    2. All your tabs have different columns? what's the column you want to copy and when does the data start?
    3. Where is the location of the files to import?
    4. Every time you import do you want to add new data or replace the data completely.

    I hope that's not a lot of questions.

    Thanks

  3. #3
    Registered User
    Join Date
    01-25-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: VBA open file, insert data, close file by tab.

    Thank you for the quick reponse!
    1. Anything with the same first word will go to the same file. "Cabbage CP" and "Cabbage SA" open the same Cabbage 2013 file. The destination file looks exactly like the source file i posted but its much longer.
    2. I mainly need the last columns that are in black boxes
    3. C:\Master Products
    4. I need a running total of the data. I create a new file once every year.

    Sorry if I double or triple posted. I kept putting the wrong name/ location for the destination folder.

    Thanks for any help!

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA open file, insert data, close file by tab.

    Can you post a sample of Cabbage 2013? I still see different headers in the file tabs.

    Thanks

  5. #5
    Registered User
    Join Date
    01-25-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: VBA open file, insert data, close file by tab.

    Sure! I attached a 100 line sample and filtered by date.

  6. #6
    Registered User
    Join Date
    01-25-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: VBA open file, insert data, close file by tab.

    Please let me know if you need anything else or have any suggestions on how to get started

  7. #7
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA open file, insert data, close file by tab.

    Hi,

    I am sorry I could not reply earlier. I was looking at your code. With the new requirements and all the new information I cannot come up with a solution. The main problem here is to determine whats copied already and what has not.

    Hopefully someone else will help us with this.

    I was wondering maybe a Vlookup from different workbooks is all that's needed.

    I am sorry I cannot help

  8. #8
    Registered User
    Join Date
    01-25-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: VBA open file, insert data, close file by tab.

    Do you think it would help if I number the transactions/lines. This way I can set a tiny macro at the end to remove the dupes?

+ 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. How do I open, insert a table, save & close a word file via excel
    By partha.raha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2015, 12:40 AM
  2. 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
  3. VBA to open a file, update/refresh all data and close file?
    By brianjluke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2013, 02:27 PM
  4. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  5. 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

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