VBA data update not working properly

  • I'm using code to update data in the blue table based on values in the orange table when the "Order" and "Notification" combination matches. It works except it is adding the last row of values from the orange table to the blue table, even if it doesn't find a match.


    I've posted the file with the code I'm using inside, one click of the button will show what I mean here. I only want it to update when it finds a match, blank cells shouldn't count toward this.

  • This looks the same as your previous question.


    I don't understand why you have two tables. You should maintain all the data in one table, adding a row for each update then you can easily track order changes

  • Originally this process was for another group to do and was meant for keeping a running track of the jobs that were updated by them, but without duplicates, however I'll be running the process myself so there won't be 2 tables.


    Yes this is part of the same workbook, but was a different issue of the code updating values for something that didn't exist, so I made a different thread, I can reply to the other thread with this if that is a better way to do it.


    I know you don't understand why I am doing it this way, but was still curious as to why the code is dropping a value in when it doesn't find a match.

  • I'm looking at the code.


    1. Your variables are declared incorrectly, you don't specify a type in several so they will default to variants.

    2. Your naming convention is difficult to follow and there are no comments in the code to help.

    3. Using an On Error statement hides errors, you only do this after fully testing, e.g. Sheet14.ShowAllData will error because that sheet does not exist.

    4. These two variables refer to the same thing


    Code
    1. Set clkupdate = Sheets("CLICK Schedule Update")
    2. Set CLKSchedule = Sheets("CLICK Schedule Update")

    What are you checking for?

  • Sorry, not the most experienced with VBA yet :( but I've commented where I could, and separated out the variables to what I think they should be, let me know if this is a little better to figure out.