I need a macro to only copy those sheets with yellow highlight and save into another workbook.
Can you add it in the macro below?
Thanks!
Here's the macro to copy and save to another workbook:
Please Login or Register to view this content.
I need a macro to only copy those sheets with yellow highlight and save into another workbook.
Can you add it in the macro below?
Thanks!
Here's the macro to copy and save to another workbook:
Please Login or Register to view this content.
Last edited by arlu1201; 01-03-2014 at 01:36 AM. Reason: Use code tags in future.
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
Are the sheets themselves highlighted or the tabs for those sheets?
If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)
You can't do one thing. XLAdept
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin
Sorry.
It copy all sheets and doesn't highlight those with difference within the 2 workbooks
Here's the code:
Please Login or Register to view this content.
Hi JeffBoy,
I've made some changes - but I can't test the program - so, take care!
Please Login or Register to view this content.
Thanks xladept!
What I need is a macro that can compare two sheets (with the same sheet name) in two different workbooks and save only the sheet of latest workbook with changes into a new file. I have two options below (any of the two options will do):
Option 1:
A macro that can compare two sheets (same tab name) in two different workbooks and saves only those sheet with changes in a new workbook.
Option 2:
A macro that can compare and highlight in yellow and saves only those with highlight in new workbook.
Here's the script to highlight the difference in each sheet
Here's the script to save the file with changes, but this script saves all sheets.Please Login or Register to view this content.
Or just make a script that will copy only those sheets whose cells have highlight in yellow in a new workbook.Please Login or Register to view this content.
Again, many thanks for your help.
Thanks,
Jeffboy
Last edited by jeffboy29; 01-03-2014 at 05:33 AM.
Hi Jeffboy,
Are you saying that the changes I made in your program didn't work? What is your program not doing? Are you getting any error messages?
Can you attach a sample workbook? Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.
Click on GO ADVANCED and use the paperclip icon to open the upload window.
View Pic
Hi Xladept,
I have 2 files that needs to compare:
Book 1 - current file w/ 3 sheets namely T0, T1 & T2
Book 2 - previous file w/ 3 sheets namely T0, T1 & T2
If there are changes in the sheets in book 1 by comparing it with book 2, it will save only the sheet with changes (in book 1) in a separate workbook and the filename will be the sheet name.
You can highlight those cells with changes if you want (this is optional) the main purpose is to just save only those sheet that have changes.
Example: T0.xls; T1.xls (assuming these are the sheets with changes)
Book1:
T0 - added A7 Code & Description (output should be T0.xls after comparing with Book2)
T1 - no changes (no output file)
T2 - added C7 Code & Description (output should be T2.xls after comparing with Book2)
Hope you can help me.
Thanks,
Jeffboy
Hi Jeffboy,
Here's a start:
Please Login or Register to view this content.
Thanks Xladept,
However, I want that to save those with changes in a separate workbook. The code that you sent save it in the OutputBook.xls both the T0 & T1 sheets, it should be separate.
Can you also change the workbook name in below code to standard (i'm having subscript out of range error) that's why i need to change it to Book1.xlsx and Book2.xlsx respectively.
Just to add that I also have T4, T5, T7, T8, T9 & PN sheets that I need to compare in addition to the T0, T1 & T2 (sorry i didn't include in the example).Please Login or Register to view this content.
Another requirement is that the naming convention of the output file should be based on the parameter sheet (see attached file) can you include below script:
MWIO_T5_2014-01-03.xls
wherein
MWIO is the Office Code located in "Parameter" sheet - B6
T5 is the sheet name
2014-01-03 is the date string
Thanks a lot for your help.Please Login or Register to view this content.
Jeffboy
Last edited by jeffboy29; 01-06-2014 at 02:03 AM.
Hi Xladept,
Here's the code that I'm working on now:
Maybe you could edit to make it work. I'm having subscript out of range error.
Again, thank you very much for your help.Please Login or Register to view this content.
Blessings!
Jeffboy
Hi Jeffboy,
I'm proceeding on the assumption that the previous book is just like the current one??
Edit: Try this
BTW - you can either name your books Current and Previous or change my code.Please Login or Register to view this content.
Last edited by xladept; 01-06-2014 at 05:32 PM.
Hi Xladept,
The previous workbook is the same with the current except that I added T4, T5, T7, T8, T9 & PN as additional sheets.
Im having runtime error: method 'Copy' of object'Worksheet' failed on
Please Login or Register to view this content.
The code is not working based on the requirements. Could you please check the script that I'm currently working.
Maybe you could start from there.
Thanks for your prompt response.
Thanks!
Jeffboy
Last edited by jeffboy29; 01-06-2014 at 10:35 PM.
Hi Jeffboy,
Are you running my code as written or have you made any changes??
I ran it again - no problem??
Last edited by xladept; 01-07-2014 at 04:39 PM.
Hi Xladept,
Thank you for your time.
I tried to use your script below
Please see attached screenshot for "OutputBook"Please Login or Register to view this content.
Comments:
1. Is it possible not to use "Book1.xlsx" & "Book2.xlsx"? So that I will not rename the files that I will compare. The script must read that it needs to compare the two open excel files.
2. The filename of the "OutputBook" should be
MWIO_T5_2014-01-03.xls
wherein
MWIO is the Office Code located in "Parameter" sheet - B6
T5 is the sheet name
2014-01-03 is the date string
3. The "OutputBook" doesn't save automatically.
4. The outputbook includes all the sheets even if no data in it. Can you make it work to have only the sheets with changes and save each sheet as separate workbooks?
5. The actual file that I'm going to use are the attached files below. Can you make the above script work on the attached files.
Again thank you very much!
Regards,
Jeffboy29
Last edited by jeffboy29; 01-08-2014 at 03:52 AM.
Hi Jeffboy,
You should try the Post #11 program:
I'll try it this way: *Result** ran to completion - no messages - no problem??Please Login or Register to view this content.
Last edited by xladept; 01-08-2014 at 03:53 PM.
Hi Xladept,
Thanks the script works on the sample files that I gave to you!
One more thing, can you include this at the beginning of the script so that i will not rename the file as Book1, Book2, etc...
Can you also add message box saying "Report Completed. Please check folder for generated files" after running the script.Please Login or Register to view this content.
Error:
I'm running the script in the actual files (see attached files) that I'm working and I'm getting a Runtime error 1004 Method 'Copy' of object_Worksheet failed on
The COA Tracking Template_Vision XL is the current file where you will run the script.Please Login or Register to view this content.
FYI:
I have invisible sheet named Ls_XLB_WorkbookFile, maybe the error was with this sheet.
Thanks a lot for your help.
Regards,
Jeffboy29
Last edited by jeffboy29; 01-09-2014 at 09:14 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks