I'm new to this forum, and hoping someone can help me use Excel more efficiently at work. Thanks in advance for any help you guys might be able to provide! 
Background - I handle all the billing for a small ambulance company. Until I can learn how to create and maintain a database, I'm using a spreadsheet to keep up with our transports, claims status, etc. Each transport is added to the spreadsheet in a new row, with an account number in column B that is unique for each individual patient. When we transport a patient that we've never transported before, I simply find the highest account number and add 1 to it, creating a new account number. However, when we haul someone that we've already transported in the past, I have to find one of the previous entries for that patient in the spreadsheet in order to look up the patient's account number so that I can fill it in.
Objective - What I'm trying to do is figure out a formula that utilizes VLOOKUP to auto-fill the account number (column B) for patients whose social security number is already in the SSN column (column M), but it would need to create a new account number for new patients whose SSN isn't already in that column. The following is the formula I've tried using thus far (for the account number cell in column B, row 81):
=IF(VLOOKUP(M81,B2:M80,2,0)>0,VLOOKUP(M81,B2:M80,2,0),MAX(B2,B80)+1) Obviously, I'm doing something wrong, because the result is "#N/A".
If anyone can tell me what I'm doing wrong, or a better formula to use, I'd really appreciate it!
Background - I handle all the billing for a small ambulance company. Until I can learn how to create and maintain a database, I'm using a spreadsheet to keep up with our transports, claims status, etc. Each transport is added to the spreadsheet in a new row, with an account number in column B that is unique for each individual patient. When we transport a patient that we've never transported before, I simply find the highest account number and add 1 to it, creating a new account number. However, when we haul someone that we've already transported in the past, I have to find one of the previous entries for that patient in the spreadsheet in order to look up the patient's account number so that I can fill it in.
Objective - What I'm trying to do is figure out a formula that utilizes VLOOKUP to auto-fill the account number (column B) for patients whose social security number is already in the SSN column (column M), but it would need to create a new account number for new patients whose SSN isn't already in that column. The following is the formula I've tried using thus far (for the account number cell in column B, row 81):
=IF(VLOOKUP(M81,B2:M80,2,0)>0,VLOOKUP(M81,B2:M80,2,0),MAX(B2,B80)+1) Obviously, I'm doing something wrong, because the result is "#N/A".
If anyone can tell me what I'm doing wrong, or a better formula to use, I'd really appreciate it!