Search code examples
excelexcel-formulaexcel-automation

Using excel formula that does not overkill the file to automate process


I have an Excel dataset and I can't use any plug-ins - only Excel formulas, for the following task: There is a table: Column A, containing text labels, and Column B, containing numbers corresponding to each label (not in an ascending order). The task is: when making a new unique entry in Column A, there should be a way to find out which numbers are already taken and/or which numbers are available to be used in Column B. Please advise as to which formula to use, whether a different sheet containing all the available numbers should be made etc.


Solution

  • Say we already have data in cols A & B like:

    enter image description here

    Each unique item has its own number. We are going to make an entry in A21. The following formula will assign an old number if the item appears above and it will assign a new, unused, number if the item does not appear above:

    In B21 enter:

    =IF(A21="","",IF(COUNTIF($A$1:A21,A21)=1,1+MAX($B$1:B20),INDEX($B$1:B20,MATCH(A21,$A$1:A20,0))))
    

    Naturally, you would adjust the formula to the point you want to make new entries.