VBA if value exists, update values in relevant columns, else add value and relevant data

  • Could you post an updated copy of your file and explain your new request in detail?

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Sure, the main workbook has become pretty robust, so I've parsed out what I'm having trouble with to this workbook which contains the button/code and some sample data. If you notice on the tracker sheet, there are duplicate Order numbers, but the current code only updates the first match that it finds and moves to the next unique order number and updates that.


    What I would like it to do, is update every instance of the order number, rather than just the first match it finds. Does this make sense?

  • Try:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Hm it seemed to work the first time I ran it, but I cleared out the data in the tracker (destination sheet) and ran it again and it only populates the first row. Odd that it populated everything the first run but can't get it to work again.

  • Please attach a copy of the file that is not working.

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Welp, I tried the same file/same code on a different computer and it works fine. Not sure what happened with the one that didn't work ?( question about this code though, is there a way to specify which columns in the destination sheet that the data will be inserted to? Noticed the way it is right now I could only get it to paste into the 2 columns adjacent to the first column.

  • is there a way to specify which columns in the destination sheet that the data will be inserted to

    If the column will always be the same, then change the column reference (the number 1) in the code below to the number of columns to the right where the data should be inserted. For example, if you want to paste 5 columns to the right, change the 1 to 5. If the column will not always be the same then the code will have to be modified to prompt for the desired column. Please advise.

    Code
    1. fnd.Offset(, 1)

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.