+ Reply to Thread
Results 1 to 23 of 23

Copy all "active" data from a worksheet from every workbook in a folder.

  1. #1
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Copy all "active" data from a worksheet from every workbook in a folder.

    Hello :>

    I am in need of a macro which will run in document CopyBriefs

    It will copy the "active" lines of a Title Summary worksheet on every SKU document in a folder.

    I have provided a sample SKU document and CopyBriefs document

    Please note, the Title Summary worksheet sheet is a reference to the Brief worksheet. So when I say "active" lines I mean the lines which aren't referencing blank/0 values.

    (Sample provided would be lines 2-7 Excluding headers)

    Copy Briefs.xlsm Test SKU.xlsx

    Thank you for your time.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Your question is not very clear.

    It will be good if you explain - what needs to be copied where and based on what condition.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    In your MODULE1 is a macro ImportBriefs that might work if you removed the second OPTION EXPLICIT halfway down that module. You can only have that once in a module at the top.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Thank you for the response,

    Hi Arlette,

    I would like to run a macro from CoppyBriefs.xlsm, which will open every SKU file in Y:\2013\~Product Briefs\01. January\

    (Sample is Test SKU.xlsx) and copy the contents from the Title Summary sheet.

    This information could be any amount of rows, so I would like to copy only the active data. (In the sample Test SKU.xlsx there is a Header, a Parent line (line 2) then the component lines below it, these are a reference from the Brief work sheet and could be a varied number of rows)

    So in the sample I would copy rows 2-7 on Title Summary.

    Hi Jerry, apologies. I left the Current Macros I had in there as a reference. They currently work very well, you might recognise the macro from http://www.excelforum.com/excel-prog...workbooks.html
    But it only copies with header line, so isn't *quite* what I am after.

  5. #5
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Hello, I don't suppose there are any suggestions after the new information supplied?

    The issue I'm having is with the code to copy only the rows of data that do not equal blank/zero.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Can you tell me which sheet's data should go to which sheet in the Copy Briefs file? There are 2 sheets in each file so its confusing.

  7. #7
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Hi Arlette,

    each [Test SKU.xlsx]Title Summary! sheet will copy into [Copy Briefs.xlsm]Product Brief! I hope this helps clarify.

  8. #8
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Hello, the code below isn't quite working. But I feel it's very close, please advise if this is any help

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Which part of the code is not working?

  10. #10
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Please Login or Register  to view this content.
    This is copying data, but not the correct data. I believe due to the "NR"

    Because it has NR= NR+1 this is just going to 1 row down on each change in file correct? But each file could have multiple lines. I need to be pasting to the first empty row on this workbook.sheet wsOutput = ThisWorkbook.Sheets("Product Brief")

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Please Login or Register  to view this content.
    should be written as
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    When I had it set to (xlup) originally. The Macro cycles through each file and when I look at the end result, it is blank.

    I tried again with the same outcome.

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Ok, maybe i need to look at your whole code again. Let me check or else i will write something afresh for you.

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Try this code -
    Please Login or Register  to view this content.
    Last edited by arlu1201; 10-22-2012 at 08:41 AM.

  15. #15
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Hi Arlette, thank you for the update.

    I believe there are issues because the 'Title Summary' contains links to the 'Brief' Sheet.

    So in the master document after the macro is run, one of the cells shows.
    ='Y:\2013\~Product Briefs\01. January\[BHE4490 UFC Presents the Ultimate Fighter Season 11.xlsx]Brief'!$D407

    Can I please have the code you supplied to include an option for open as ReadOnly:=True and also to Paste the data with Formatting and Values?

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    I have edited the code above to paste values and number formats.

    I do not think you need to open as read only. Even if you open as a normal file, since you are pasting values, it should not create any problems for you.

  17. #17
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Hi Arlette, the reasoning for opening as read only was due to each file having a warning to open as read only set. Apologies I did not specify this was the case earlier.

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    I have edited the code again. Let me know if that works for you.

  19. #19
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Please Login or Register  to view this content.
    Compile Error - Syntax Error displays as red when I copy the code.

  20. #20
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Sorry, my bad. Replace this line
    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Thank you Arlette, that has amended the issue!

    I'm getting another strange outcome, but I'm not sure if it's easy to resolve without having access to all of the files i'm copying.

    It's getting through several files and then it will copy the headers of the files and the 2nd line.

    When I check the files, the headers are on A1 and not A2, so i'm not sure why this is occurring!

    Also is there an easy way to exclude files that begin with a ~ ?

    If our Mac users open a file it creates a copy beginning with ~, which will error when it tries to open.

    Please Login or Register  to view this content.
    Also, is there a way to copy cell Formatting and Values?

  22. #22
    Registered User
    Join Date
    09-02-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Thank you for your help Arlette,

    I have changed the code to include a copy paste special values on each file. Because the SKU\Title Summary! contained links to another Sheet, I wanted to find all cells that contained a 0 (after pasting values) in column A, then delete all of those rows.

    The macro then copies the "active" lines to the Copy Briefs.xlsm\Product Brief!

    Please Login or Register  to view this content.
    I also needed to include a line after each copy/paste to empty the clip board, as I was receiving a warning message.

  23. #23
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all "active" data from a worksheet from every workbook in a folder.

    Ok great you got it resolved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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