In Column B I want to have unique 4 digit numbers for series of product related to Column A. Problem is, Column A may have 4 of the same product what would then make column B equal the same.

Example.
Col A, Col B
Apple, 1001
Apple, 1001
Apple, 1001
Orange, 9005
Orange, 9005
Banana, 2500
Apple, 1001

If someone tries to input a new fruit in Column A, example Pear, then I would like to be able to either choose or assign a new number that will not repeat with any of the other existing fruits.

I don't want the new fruits to assign new codes in numeric value, ie 1001, 1002, 1003...rather choose from a random list from 1000 to 9999, example 1001, 2529, 6232, etc.

Any creative way of doing this???