That was just a sample; I assumed you'd have to adapt it to your own details and coding style. And anyway, I'm more a teach-a-man-to-fish kind of guy; I'd rather explain it to you, and have you work out for yourself how to do it based on my explanation; then you'll really know how, and be able to do it next time.
Let's start with the helping column in IN-OUT. I see there's a column there labeled LOCATION; can you tell me what that's for? The formula is complicated enough that I didn't try to figure it out, but "location" sounds like it might be related to the sort of thing I'm talking about. The resulting values, though, don't look at all like a row number, so maybe it's for some other purpose entirely.
What I want to create in IN-OUT is a new column that has just a row number in it. Let's say it'll be in col K. If IN-OUT!F8 says "XYZ", and part "XYZ" is found on row 13 in the DATABASE worksheet, then IN-OUT!K8 will have the value 13. You follow? You would use the MATCH function to accomplish this.
This gets you two advantages. One is that if the operator enters an invalid part number, col K will immediately show that it's an error, so the operator will see it right away. The other is that your program doesn't have to search through DATABASE looking for a matching part number; it can go straight to row 13 (or whatever value it finds in col K) and do its thing there.
If the whole thing is clear to you now, great. If not, that's alright; let's get col K working (or whatever column you want to put it in), and we'll modify your program code next.