+ Reply to Thread
Results 1 to 28 of 28

Compare two sheets, Highlight rows in second sheet that does not appear in the first

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi There.

    I am trying to create a spreadsheet for scheduling purposes. I have been doing a lot of reading and have not come up with a solution. I admit I do not now much about VBA. Here is an outline of what I am trying to do. I do hope someone out there is able to help me.

    1) Delete green rows in all sheets except "Machine All"
    2) Highlight rows green that appear in other sheets but are not in "Machine All" based on contents of three cells.
    3) Move green rows in all sheets, except "Machine All", to the top of that sheet.

    Not sure if this is possible or how hard it maybe. I have tried a lot of VB code I have found and I have not been either able to get it working or I was not able to modify it to do what I needed. I have seen a lot of great answers in these forums and thought that this is my best chance at getting some help to figure this out.

    I greatly thank anyone who is willing to help.

    Triump

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    It shouldn't be very difficult:

    Attach a sample - bereft of any confidential matter!
    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

  3. #3
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Well... That is great to hear.

    I have attached a sample of my sheet.

    So here is a little more info of what I am trying to do.

    The first thing is to delete all rows that are colored green. Then we look at the first row from "Machine All". We then look at the column "Resource ID". Here is a break down of the Resource ID's and their corresponding sheets.

    CNC MILL SML 1 = CNC MILL SML 1
    CNC MILL LRG 1 = CNC MILL LRG 1
    CNC LATHE 1 = CNC Lathes
    CNC LATHE 2 = CNC Lathes
    KEARNS = KEARNS
    TOS SU125 = Tos
    LATHE = LATHE
    SMALL MILL = SMALL MILL
    Cut =Cut

    If the "Resource ID" is CNC MILL SML 1, we check to see if the row we are looking at exists on CNC MILL SML 1. If it does, we do nothing. If it do not. We copy that row to the bottom of CNC MILL SML 1 and highlight it yellow. I would like to check to see if the row exists on CNC MILL SML 1 by using the columns "Description", "Base_ID", "Part_ID" and "Drawing ID". If there is a row that is on "CNC MILL SML 1" but not on "Machine All" I would like to color it green and move it to the top.

    I hope this makes some sort of sense.

    Thank you very much for your help. It would be so helpfull to get this sheet working.

    Triump
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I've got about half of it coded - I'm now working on the "corresponding sheets"

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I think I got it - try:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Wow. That code looks very nice. Great job. I would love to buy you a beer.

    I did try the spread sheet. There are a few issues.

    When I first run the macro it copies all the rows to the proper sheets but it highlights the first row on the second sheet green every time. After I change the newly added rows from yellow to no fill and run the macro again. It changes the rows green again. It should only change them green if a row appears on a sheet but does not appear on the master sheet.

    I hope this is an easy fix.

    Thank you for your help.

    Triump

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi Triump,

    I've realized that I was solving the wrong problem - so, after I fixed it, I'm going back to the drawing board. I was making the wrong things green and I'll have to come up with something else

  8. #8
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Ahh. I am sorry to hear that. Was hoping it wouldn't have been to much trouble for you. Your code looked very nice as well.

    Hope it doesn't give you to much trouble. I appreciate your efforts.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi Triump,

    Try this and let me know:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi Triump,

    Try this and let me know:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    It looks great. The only issue I see is the CNC Mill LRG 1 sheet. When I run the macro the first line is highlighted green and the other lines have no fill when they should have be highlighted yellow.

    Aside from that it seems to work great.

    Thank you very much.

  12. #12
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I am very sorry. I mussed have messed something up. There is no issue with the second sheet. I just tried it again and it seems to be working great.

    Thank you very much for your effort. This will be so helpful.

    Thank you
    Triump

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    You're welcome and thanks for the rep (finally deserved)!

  14. #14
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I have two questions.

    Do I need to change anything if I add a new column?

    Right now the macro copies all the rows to the other sheets starting at row 7. How do I change it to start at row 6 like machine all?

    Thanks

  15. #15
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I am quite sure your rep was well deserved before now.

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Please Login or Register  to view this content.
    See the red
    Last edited by xladept; 11-23-2015 at 11:50 PM.

  17. #17
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    That doesn't seem to much to change. I ran the code. The rows are now copied to the other sheets starting at row 6 but the code will not do anything if I add another column to Machine All as well as all other sheets. If I delete the extra row it works fine.

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi Triump,

    What column are you adding?

    BTW - I've been thinking about the "greenies" - the thing is that besides moving them to the top after the first pass, if you do nothing with them they'll be lost - so I've coded a version that will at the same time that they're turned green, they'll be appended to the master - that way a second run will put them in the correct sheet instead of eradicating them - what do you think?
    Last edited by xladept; 11-24-2015 at 03:32 PM.

  19. #19
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I am adding a column between K and L.

    If I remove the column I added, the macro works great. The only thing is it doesn't move the green rows to the top.

    As for the greenies. I want to identify the orders that have been completed the day before. So if an order is on one of the sheets that is not on the master, then it must have been completed. Color it green. Then the next day, when I run the macro, I want it to delete the green rows and create new green rows that are on a worksheet but not on machine all. I was thinking that if we deleted the green rows first, then compared the sheets with machine all, we could then mark the new differences.

    Not sure if that makes sense.

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Well - it's not the best strategy since there's no fail safe - with this version (which includes adaptation to the new Column L), you won't lose data - try it and see!

    Please Login or Register  to view this content.
    Last edited by xladept; 11-24-2015 at 08:23 PM.

  21. #21
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    That worked perfectly. One thing I did notice is that when the macro highlights rows green on sheet, it also copies those same rows to Machine All. I am not sure if that really matters. I did try a few different things with it and it didnt seem to have an effect. I have uploaded the spreadsheet with data. If you look at the sheet next to machine all, it has no green rows. If you press the update button, the top four rows turn green but then if you check the bottom of machine all those rows are they as well in green.

    I also setup a few other sheet that formats some of the data for printing. I am not sure if there is a better way of doing it. Would you mine taking a look at the extra sheets and letting me know if there is a better way of doing it?

    Thanks
    Triump

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    I'll look at it tomorrow - I'm concerned about the entries that don't belong to the RID!

  23. #23
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    The reports look pretty good to me - the "greenies" are copied to the bottom of Machine All on purpose so that the data wouldn't be lost (post #20).

    Please Login or Register  to view this content.
    I would probably have tried to write a program to generate each report from scratch (more work at the start but less work for the long run)

  24. #24
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    That is great. I cant tell you how helpful this is. I update schedules now for fun.

    Can you recommend a book or resource to help me get started in VBA?

    Thanks

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Many recommend Walkenbach one of the Power Programming versions - I paid about $20 on Amazon for my 2003 version. But, I started with the Steven Roman "Writing Excel Macros" by O'Reilly. And, Wordware author Julitta Korol writes very well - and, last time I looked, her books were inexpensive on Amazon. As a matter of Fact her 2007 VBA Programming is about $30 and I recommend that one to you


    *I have her 2000 book (bought new)
    Last edited by xladept; 11-26-2015 at 05:43 PM.

  26. #26
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi xladept

    I know you have done lots to help me with my schedule but I was wondering if you could help me with a few more items?

    1) First thing is I need is to have the colors that are on the data sheets, show up in the corresponding jobs on the report sheets. So if job 3 is colored green on CNC Mill Sml 1, then I need job number 3 on VF5 MillReport to be green also. If job 6 is colored yellow on CNC Mill Sml 1, then I need job number 6 on VF5 MillReport to be yellow also.

    2) When I run the update schedule macro, I need that macro to remove the yellow fill just before or just after it deletes the green rows. Right now it deletes the green rows, colors rows that are not on the Machine All schedule green and highlights the new jobs yellow. I need to remove the yellow fill before adding new jobs which are also be yellow.

    3) I would like to delete all the rows starting row 5 from the Report sheets. I would then like to count the rows on the corresponding data sheets, and copy the top 5 rows from the Report_Format sheet to the report sheet as many times as there are rows in the data sheet.

    4) The last thing that would be nice is if I could use the combo box that is in the Report_Format sheet and add a combo box to the material cell of the data sheet. It would be helpful if when an item is selected in that combo box, those 5 rows that correspond to that combo box turn red as well as the same item in the combo box on the data sheet was selected causing that line to go red. The same thing would happen if an item was selected on the data sheet. That line would turn red and the corresponding job on the report sheet would turn red and the same item would be selected. The two options would be Material OK and No Material. If material OK is selected then the red fill is removed from both sheets.

    I am not sure how much trouble it would be to add these things. I am hoping not too much. I would certainly be interested in forwarding you a beer for your troubles.

    Thanks

    I have attached the sheet as I have it so far.
    Last edited by triump; 12-09-2015 at 01:22 AM.

  27. #27
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Here's the first three, I'm not clear on the fourth - and am not sure that I know how to do it

    Please Login or Register  to view this content.
    Last edited by xladept; 12-09-2015 at 06:57 PM.

  28. #28
    Registered User
    Join Date
    05-14-2013
    Location
    Onatrio
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Compare two sheets, Highlight rows in second sheet that does not appear in the first

    Hi xladept

    I have been trying to learn from your code. I have been going through it trying to figure out what is going on. I was wondering if you could explain this line?

    If Not .Exists(Y) Then

    Is it comparing Y to something?

    Thanks
    Triump
    Last edited by triump; 01-15-2016 at 11:31 PM.

+ 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. [SOLVED] Compare Two Sheets and Highlight Differences
    By Blake 7 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-12-2015, 11:44 AM
  2. Compare 2 sheets, highlight duplicates on sheet 2
    By rubybegonia in forum Excel General
    Replies: 1
    Last Post: 02-17-2014, 05:33 PM
  3. [SOLVED] Compare 2 sheets, match data in 1 column, update row in sheet 2 & add new rows not matched
    By Synchronicity in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-11-2013, 01:21 PM
  4. [SOLVED] Compare two colums from different sheets and to highlight the different cell in sheet 2
    By Thinker8 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-26-2013, 04:46 AM
  5. [SOLVED] Compare name list (First name, last name) on two different sheets and highlight
    By badboynads in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-25-2013, 07:37 AM
  6. Compare 2 sheets pick up unique and copy rows to another Sheet
    By dungoc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-23-2013, 10:08 AM
  7. compare 2 sheets and remove identical rows in sheet 2
    By VBisgreat in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2009, 04:41 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