+ Reply to Thread
Results 1 to 8 of 8

VBA to copy data from excel worksheet in zip file

  1. #1
    Registered User
    Join Date
    04-19-2012
    Location
    UK
    MS-Off Ver
    Excel 365
    Posts
    41

    VBA to copy data from excel worksheet in zip file

    Hi I'm wondering if there is a reasonably simple way of doing a straight forward task. I have been looking at VBA examples of opening zip files but they are overly complex for what I want to do. If its too complex a task for VBA I may just do manually but thought I would ask for advice first.

    I currently have a macro that runs to save an email attachment from an email that is received each evening, the attachment (zip) is saved in the Documents folder and thats it. What I wanted to do was (in the morning, the email is sent in the evening) open an excel macro and run it so that it goes to the zip which contains an excel file and copies the data from the sheet (theres only one tab), ideally with a filter applied first on a particular column, then pastes that data to a new worksheet. Any help/advice would be greatly appreciated.

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA to copy data from excel worksheet in zip file

    For example, for attached files (EF1162840.xls and File1.zip), File1.zip is placed on the same folder with EF1162840.xls.
    For your actual file, change this line to location of your .zip file : ReadZip ThisWorkbook.Path & "\File1.zip"

    The macro is copying sheet "DATA" in the .zip file to current workbook.
    You said that you want to filter the column first, but I don't know what your data layout is, and what filter(s) to applied, so let this be a seperate job (not "reading inside zipped excel file" job).

    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Registered User
    Join Date
    04-19-2012
    Location
    UK
    MS-Off Ver
    Excel 365
    Posts
    41

    Re: VBA to copy data from excel worksheet in zip file

    Thanks so much, this works perfectly!
    The filter I was looking to add was on column F and is a text filter of 'begins with' the letters 'BT'. Is it possible to apply the filter before the data is selected, so that only the filtered data is then coped across?

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA to copy data from excel worksheet in zip file

    You are welcome, thanks for the rep.points.
    This code assumes that your data in .zip file start on cell A1 with continous region.
    If this doesn't work, you need to upload your zip file.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-19-2012
    Location
    UK
    MS-Off Ver
    Excel 365
    Posts
    41

    Re: VBA to copy data from excel worksheet in zip file

    No worries and thanks again. So does the code in your last post fully replace the original code or does it just need added? As I notice the 'Readzip...' command is no longer there, is it not needed to point to the right file?

  6. #6
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA to copy data from excel worksheet in zip file

    You need to delete all the code first, then add the code from post #4, then add only Sub Test() code (3 lines) from post #2.
    In short, replace Sub ReadZip() from post #2 with the new one in post #4.

  7. #7
    Registered User
    Join Date
    04-19-2012
    Location
    UK
    MS-Off Ver
    Excel 365
    Posts
    41

    Re: VBA to copy data from excel worksheet in zip file

    Again, works perfectly, thanks for your help!

  8. #8
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA to copy data from excel worksheet in zip file

    You are welcome.

    Don't forget to mark this thread as solved :
    please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Automatically copy data to another file or worksheet.
    By ghaxnavi in forum Excel General
    Replies: 0
    Last Post: 10-21-2015, 02:47 AM
  2. Replies: 3
    Last Post: 01-09-2015, 08:29 AM
  3. [SOLVED] How to copy a worksheet 86 times into the same excel file with the given name
    By 1tane1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-26-2014, 08:01 AM
  4. [SOLVED] Copy paste data on each worksheet of a file
    By nicolaforni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2013, 09:30 AM
  5. Copy single worksheet from excel file
    By Big Jim in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2013, 03:22 PM
  6. Automatically Copy Data into Worksheet from Different Excel File
    By mwgr5 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-21-2010, 01:48 PM
  7. [SOLVED] Copy a worksheet to another excel file
    By Mike S. in forum Excel General
    Replies: 4
    Last Post: 06-10-2005, 07:05 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