+ Reply to Thread
Results 1 to 12 of 12

Cell Adds One to Last Entry Used Depending On Selection

  1. #1
    Forum Contributor
    Join Date
    12-22-2015
    Location
    San Antonio, Texas
    MS-Off Ver
    2016
    Posts
    116

    Cool Cell Adds One to Last Entry Used Depending On Selection

    See attached workbook.

    There is a drop-down list in column A on sheet one. It references the "Animal" table in column A on sheet two. When a person chooses an animal in column A on sheet one, I need column B on sheet one to reference the corresponding "Animal ID" table in column C on sheet two then find the last instance it was used on sheet one and add one to it.

    Example:
    If in cell A8 I choose "Flamingo", B8 will know to reference its "Animal ID" in column C on sheet two (in this case EAS), then find that "Flamingo" was selected two times already, and then add one to make the entry as EAS-3.

    If the animal hasn't yet been selected (say yak), it would know to start it with TVA-1.

    Any help would be greatly appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Try

    =VLOOKUP($A2,Sheet2!$A$2:$C$27,3,0) & "-" & COUNTIF($A$2:$A2,$A2)
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    12-22-2015
    Location
    San Antonio, Texas
    MS-Off Ver
    2016
    Posts
    116

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Unfortunately it doesn't work. The formula sometimes references a different ID, or it'll not update if the animal selection is changed in column A, or it won't add at all. I tried to tweak it to make it work, but it still gives errors. Can you assist?

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Removed solution.

    I read the question not well enough.
    Last edited by oeldere; 08-08-2022 at 09:49 AM. Reason: File added
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Cell Adds One to Last Entry Used Depending On Selection

    See attached
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    12-22-2015
    Location
    San Antonio, Texas
    MS-Off Ver
    2016
    Posts
    116

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Can this be applied to the entire column? I seem to have to pull down the formula in the column for it to work. Entries will be added over time, and people may not know how to do this to receive the animal ID.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Try

    =IF($A2="","",VLOOKUP($A2,Sheet2!$A$2:$C$27,3,0) & "-" & COUNTIF($A$2:$A2,$A2))

    copy down as many rows as deemed necessary

  8. #8
    Forum Contributor
    Join Date
    12-22-2015
    Location
    San Antonio, Texas
    MS-Off Ver
    2016
    Posts
    116

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Is there a way to use either data validation or some other feature that will do it automatically and not have the user copy it down the column? Not everyone knows how to use Excel, and one can easily mess it up.

    Remember: People will be adding entries over time.

    I tried data validation using the provided formula as Excel has an adaptive way to applying formulae to new entries, but it didn't work.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Not that I am aware of unless you are prepared to use VBA.

    VBA example attached.

    Please Login or Register  to view this content.
    Above code goes in "Sheet1": click on tab, "View Code" and copy/paste to blank area

    Please Login or Register  to view this content.
    This code goes in a MODULE ..

    to add code

    1. Copy the sample code that you want to use
    2. Open the workbook in which you want to add the code
    3. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    4. Choose Insert | Module
    5. Where the cursor is flashing, choose Edit | Paste


    Just select in column A and Result is in B

    I changed Sheet2 to remove column B and named A:B as "Animals"
    Attached Files Attached Files
    Last edited by JohnTopley; 08-10-2022 at 10:29 AM.

  10. #10
    Forum Contributor
    Join Date
    12-22-2015
    Location
    San Antonio, Texas
    MS-Off Ver
    2016
    Posts
    116

    Re: Cell Adds One to Last Entry Used Depending On Selection

    I am still having to pull down the formula per each animal entry. Unfortunately the macro doesn't work.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Cell Adds One to Last Entry Used Depending On Selection

    It does!. Click on empty cell in A, select Animal and Code is put in B.

    I suspect the first set of code in post #9 is not in the sheet (Sheet1).

  12. #12
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Cell Adds One to Last Entry Used Depending On Selection

    Please try

    B2
    =IFERROR(INDEX(AnimalID[[#All],[Animal ID]],MATCH(A2,Table1[[#All],[Animal]],0))&"-"&COUNTIF(B$1:B1,INDEX(AnimalID[[#All],[Animal ID]],MATCH(A2,Table1[[#All],[Animal]],0))&"*")+1,"")

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need help with an Excel formula that adds additional amounts depending on a cell value
    By afprinter in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-16-2019, 02:08 PM
  2. Macro that adds or removes row based ont first cell selection.
    By MaritimeRob in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-20-2017, 01:14 AM
  3. Userform adds entry new entry instead of updating existing
    By rayexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2014, 04:27 AM
  4. If statement that adds depending on the value
    By timweb in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2013, 12:26 PM
  5. Replies: 1
    Last Post: 01-23-2011, 08:00 AM
  6. Replies: 8
    Last Post: 03-14-2010, 12:20 PM
  7. Auto entry depending on dropdown selection
    By breal33 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2008, 07:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1