Vendor list lookup and change if duplicate

imeade

New Member
Joined
Jun 28, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that creates a vendorID based on a person's name and assigns an "01" at the end, this is in column A. When it creates the vendorID, I need it to check if the vendorID already exists in column G. If the vendorID already exists, then it would move on to the next number vendorID.

For example: "JOHNDOE01" is created, but then does a lookup to check if it exists, if it exists, then it would move to "JOHNDOE02" and it would continue to increase to JOHNDOE03, 04, etc.

I have tried vlookups with ifna, along with index/match, but this logic doesn't work to continue to increase the increment.

I thought I had figured it out via the formulas in cells A2 and A3, but unfortunately it doesn't work. The formulas in columns B and C were just trying out other things to no avail.

Thanks in advance for the help.

vendor.xlsx
ABCDEFG
1VendorPayeeNameExisting Vendors
2JOHNDOE02JOHNDOE01JOHNDOE01JOHN DOEJOHNDOE01
3BRIANHOPKI02BRIANHOPKI02BRIAN HOPKINSJOHNDOE02
4JOHNDOE03
5JOHNDOE04
6BRIANHOPKI01
7BRIANHOPKI02
8BRIANHOPKI03
9JOHNDOE02BRIANHOPKI04
10JOHNDOE01
11
12
13
14
15
Lookup
Cell Formulas
RangeFormula
A2:A3A2=IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"01",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"01",LEFT(SUBSTITUTE(D2," ",""),10)&"02")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"02",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"02",LEFT(SUBSTITUTE(D2," ",""),10)&"03")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"03",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"03",LEFT(SUBSTITUTE(D2," ",""),10)&"04")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"04",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"04",LEFT(SUBSTITUTE(D2," ",""),10)&"05")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"05",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"05",LEFT(SUBSTITUTE(D2," ",""),10)&"06")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"06",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"06",LEFT(SUBSTITUTE(D2," ",""),10)&"07")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"07",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"07",LEFT(SUBSTITUTE(D2," ",""),10)&"08")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"08",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"08",LEFT(SUBSTITUTE(D2," ",""),10)&"09")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"09",G:G,1,FALSE)=LEFT(SUBSTITUTE(D2," ",""),10)&"09",LEFT(SUBSTITUTE(D2," ",""),10)&"10")),LEFT(SUBSTITUTE(D2," ",""),10)&"01")))))))))
B2B2=IFNA(VLOOKUP((LEFT(SUBSTITUTE(D2," ",""),10)&"01"),G:G,1,FALSE),"Not Found")
C2C2=IF(ISNA(INDEX(G:G,MATCH(B2,G:G,0),0)),"TESTING",INDEX(G:G,MATCH(B2,G:G,0),0))
B3B3=IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D3," ",""),10)&"01",G:G,1,FALSE)=LEFT(SUBSTITUTE(D3," ",""),10)&"01",LEFT(SUBSTITUTE(D3," ",""),10)&"02")),IFNA((IF(VLOOKUP(LEFT(SUBSTITUTE(D3," ",""),10)&"02",G:G,1,FALSE)=LEFT(SUBSTITUTE(D3," ",""),10)&"02",LEFT(SUBSTITUTE(D3," ",""),10)&"03")),LEFT(SUBSTITUTE(D3," ",""),10)&"01"))
C9C9=IF(LEFT(SUBSTITUTE(D2," ",""),10)&"01"=VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"01",G:G,1,FALSE),LEFT(SUBSTITUTE(D2," ",""),10)&"02","TESTING")
C10C10=VLOOKUP(LEFT(SUBSTITUTE(D2," ",""),10)&"01",G:G,1,FALSE)
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,829
Messages
6,181,218
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top