in the spirit of learning - the "For" starts before the "if", so in my mind logic dictates that the "if" should end first, and be contained inside the "for"
You are absolutely correct. Think of the for..next and if..endif constructions as a for..next bracket and an if..endif bracket, and the rules state that the brackets can never cross (i.e. one always has to be inside the other). If you single step through the code (F8 in the debugger), you will see that if the 'exit for' is OUTSIDE if..endif (i.e. after the endif) that we will ALWAYS exit after the first invoice number is checked. If is inside the if..endif, so that when we find a MATCHING invoice number, we EXIT and don't process any more invoice numbers.
s there an easier way to carry on from here and add alll the relevant fields (30ish) under the cmdUpdateDetails command button subroutine without defining each one as a string individually
There may be an easier way, but I don't know of one. Your code is very easy to read and follow as is. I write my code in a manner similar to yours.
One difference is I usually don't like to reference column numbers for items directly in the code. Especially if the column numbers (or row numbers) appear in more than one place in the code. That way if the worksheet design changes, VBA changes to column numbers only have to be in ONE PLACE. I put all those definitions in a special (ordinary) code module I call 'ModConstants'. For example:
Module 'ModConstants':
Module 'Module1' or ThisWorkbook Module or a Sheet Module:
Lewis
Bookmarks