+ Reply to Thread
Results 1 to 14 of 14

Highlight Rows which are NOT found.

  1. #1
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Highlight Rows which are NOT found.

    Hi all, I am very new to VBA and struggling to make sense of it all!!

    I am trying to help my wife with a spreadsheet she uses a lot. Basically I need to find a row in sheet 1 (Tracking) where Column B is the same in both and where column G in sheet 2 (BL) matches column K in sheet 1, and if so, update the data in sheet 1 column W with the data from sheet 2 column I. Now I have already had help with that bit and it works a treat Thank you....

    Now I am trying to highlight any rows in sheet 2 which do not match....

    I have tried and it works on my test but when I run it on the actual spreadsheet (1 sheet has 8000 rows and one has 5000 rows) it takes forever and then crashes Excel! The OverwriteMatchedData function works fine its just the HighlightNotFound bit that breaks it, I was wondering if they can be combined?

    Can anyone help?? It would be greatly appreciated. My code is below:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by theeachi; 03-02-2020 at 06:13 AM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro takes forever and and then crashes Excel, help.

    Sorry.

    I hate to say it but your approach is all wrong.

    Give me a few minutes and I will show you.

    Just trying to get my head around your requirement.

    What does this mean? I need to find a row in sheet 1 (Tracking) where Column B is the same in both.
    Last edited by mehmetcik; 03-01-2020 at 09:19 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Re: Macro takes forever and and then crashes Excel, help.

    I suspected as much, I think I have a lot to learn.

    "I need to find a row in sheet 1 (Tracking) where Column B is the same in both." just means Column B needs to match in both sheets, sorry I didn't explain it very well.

    thank you

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro takes forever and and then crashes Excel, help.

    Ok I have it. Please wait.

    So we are replacing "Manifest" with the Processed Date?
    Last edited by mehmetcik; 03-01-2020 at 09:31 PM.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro takes forever and and then crashes Excel, help.

    Nearly there. Formula for AI2 on Tracker then fill down. =IF(ISNA(MATCH(B2,BL!$B$1:$B$20,0)),"Manifest",IF(K2<>INDIRECT("BL!G"&MATCH(B2,BL!$B$1:$B$20,0)),"Manifest",TEXT(INDIRECT("BL!I"&MATCH(B2,BL!$B$1:$B$20,0)),"dd/mm/yyyy")))

    That formula works.

    So.

    Find last row in Tracker.

    Insert this formula in Column AI.

    Copy Paste Formula in Column W

    Delete Column AI.


    There are no Loops. So this should be fast.



    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-01-2020 at 10:11 PM.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,567

    Re: Macro takes forever and and then crashes Excel, help.

    Did you try to adapt Jindon's code from your previous thread ?

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,645

    Re: find a row in sheet 1 (Tracking) where Column B is the same in both.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    I changed it for you this time using your own description

  8. #8
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Re: find a row in sheet 1 (Tracking) where Column B is the same in both.

    I am really sorry, I didn't realise.

    Thank you for pointing it our, I have changed it now and I will be more careful in future.

    thanks again

  9. #9
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Re: Macro takes forever and and then crashes Excel, help.

    Quote Originally Posted by mehmetcik View Post
    Ok I have it. Please wait.

    So we are replacing "Manifest" with the Processed Date?
    Good morning, yes but that bit OverwriteMatchedData() works great and its quick, it is the highlighting of the rows HighlightNotFound() that doesn't work. It works on small rows of data but when it gets over 5000 rows it causes Excel to not repsond.

  10. #10
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Re: Macro takes forever and and then crashes Excel, help.

    Quote Originally Posted by bakerman2 View Post
    Did you try to adapt Jindon's code from your previous thread ?

    Please Login or Register  to view this content.
    Good morning, I did but it didn't overwrite with the correct date. It found matching rows and overwrote the date but instead of using the date from the matched row it used the date from the corresponding row. So for example if Row 66 in sheet 2 matched Row 10 in sheet 1, it found it but overwrote it with the date from Row 10 in sheet 2 and not Row 66 in sheet 2. I couldn't work out how to change it. I hope that makes sense??

    thank you

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,567

    Re: Highlight Rows which are NOT found.

    I just tried all 3 codes (mine, jindon's & mehmetcik's) in the example file you posted in your 1st post and they all gave me same result so no, it makes no sense to me.

  12. #12
    Registered User
    Join Date
    02-23-2020
    Location
    Oldham, England
    MS-Off Ver
    O365
    Posts
    9

    Re: Highlight Rows which are NOT found.

    Quote Originally Posted by bakerman2 View Post
    I just tried all 3 codes (mine, jindon's & mehmetcik's) in the example file you posted in your 1st post and they all gave me same result so no, it makes no sense to me.
    Hi bakerman2, it is your code that I am using and it works perfectly (thanks again), I now just need to add something which will highlight the rows in sheet 2 that are not matched.

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Highlight Rows which are NOT found.

    Bakersmans code:

    Please Login or Register  to view this content.
    Successfully Highlights Rows that do not math on Sheet BL.

    So I assume the issue is the Tracking Sheet.

    The same or similar method would work but conditional formatting would be neater and faster.

    Select all cell select conditional formatting, select use formula: =AND(ROW()>1,$W1 ="Manifest")
    Last edited by mehmetcik; 03-02-2020 at 08:37 AM.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Highlight Rows which are NOT found.

    I didn't test my code carefully, so try this one
    Please Login or Register  to view this content.

+ 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] Creating a macro to replace a formula that takes forever to calculate
    By PaulM100 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-03-2018, 09:49 AM
  2. [SOLVED] InStr macro takes forever.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2017, 10:40 AM
  3. Macro takes forever after upgrading from excel 20007 to 2010
    By Yigal in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-05-2014, 10:45 AM
  4. Macro Takes forever To Execute
    By daveyc18 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2014, 11:14 AM
  5. Excel Sheet takes forever to save
    By JohnGault82 in forum Excel General
    Replies: 2
    Last Post: 02-09-2011, 04:41 PM
  6. Replies: 7
    Last Post: 12-19-2008, 10:57 PM
  7. hiding a few rows with a macro takes forever
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2007, 06:34 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