+ Reply to Thread
Results 1 to 22 of 22

Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighting

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighting

    Hello Everyone!

    I am using the macro below (in a string of multiple other macros) to format a report. One worksheet on this report has a listing of excess items from multiple locations. What this macro initially did (and still does) was highlight the duplicate items (by item number) and change the text to white for easier reading. The problem is that the macro has begun to highlight items that are not duplicates and it is causing a good deal of manual work. I inherited this macro, and I am having some trouble debugging it. Any help would be very much appreciated.

    Thank you!
    TCS



    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    I need a sample file with few rows but many duplicates for testing
    If solved remember to mark Thread as solved

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

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Do you have a sample file that you can upload which you used along with this code?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    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]

  4. #4
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Patel,

    Thank you for getting to me so quickly!

    Attached is an example of the tab after all of the other macros are run on it. Sorry that I could not include more information.... The only thing that is really needed is Sim Number anyway.

    Thanks,
    TCS
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    You attached a file without macro, the code you posted does not work

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, TCS,

    your macro can be simplified and amended like this (I wonīt compare the row value to the row before but to the entire column):
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Holger,


    Thank you so much for your help. I still have more testing to do, but so far it looks like the simplification worked. Thank you so much, you are THE MAN!!!

    I will update the thread as "solved" after I finish 2 or 3 more rounds of testing.


    Thanks,
    TCS

  8. #8
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Upon further review, the macro did fix some of the mistakes on the smaller reports, but the larger reports began to have mistakes with the new code. It seems that the errors usually happen when there is a long run of duplicates and the code just whites out everything skipping over 2 or 3 lines that should have been left alone.

    Any further help on this issue would be greatly appreciated, and thank you to Holger for your code.

    Thanks,
    TCS

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, TCS,

    could you please attach a sample for that (maybe only with the column with the sim numbers) for a check? The code should not only compare the data to the row ahead but to the whole range from Row1 to the active row and write down the number of items found - no need for the data to be sorted first.

    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Attached is the sample that you requested. Thank you!
    Attached Files Attached Files

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, TCS,

    when I look into the workbook and insert the formula into Column V every line with 1 is still in black while all others are in white. Maybe I just donīt get the point of which lines were to be visible.

    Ciao,
    Holger

  12. #12
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Holger,

    The first line of every new "Sim Item" should be black, while all of the others should be white. The following lines in the "PO Alerts Sample" should be black and not white: 122, 127, 134, 187, 205, 209, 323, 324.

    I am sorry that I did not explain this more clearly.

    Thanks,
    Tony

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, Tony,

    row 122 shows 00281 which is found in Rows 2 to 6 and 122 to 126. The differences are in Columns O and R.
    row 127 at 8 to 14 and 127 to 133, difference in Column R.

    So we need to take Column R into our formula as one more criteria?

    Ciao,
    Holger

  14. #14
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Holger,

    My mistake on that one. I actually think the extra criteria would be on column c - Branch Plant.

    Sorry about that.

    Thanks,
    Tony

  15. #15
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, Tony,

    letīs take Sim Nr. 00466: columns A to I are empty in the example and thus would lead to same result as in the macro already on hand.

    What about trying to run the simplified macro with the formula that you had created in your original macro and look at the results then? Originally the rows were compared one by one while I changed it (without knowing too much about the workbook) to look at every entry made.

    Ciao,
    Holger

  16. #16
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    I was not comfortable pasting a bunch of information on to the thread and that is why those columns are empty.

    The original code was missing highlights.

    How would I be able to include looking at column C as well as column V?

    Thanks

  17. #17
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Could we sort using column R then?

  18. #18
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, Toy,

    using two columns: insert a column into Column V and concatenate teh contents of both columns wanted, the do the normal check but to the newly created column as reference (instead of Column N), formula for that could be
    Please Login or Register  to view this content.
    Same would go for the use of Column R.

    Ciao,
    Holger

  19. #19
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    I am trying to concatenate V and C into the column but I can't seem to get it to work correctly.

  20. #20
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Hi, Tony,

    please have a look at the attached workbook. Concatenate is on N, C and R.

    Code used:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Holger,

    It highlights the top row (column names) whenever there are no highlighted rows in the sheet.

    Thanks,
    Tony

  22. #22
    Registered User
    Join Date
    09-27-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Current Macro Highlights Duplicate Records and Whites them out, but is over-highlighti

    Holger,

    Thank you very much for helping me out with this. You are the MAING!!!

    Thanks,
    TCS

+ 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