+ Reply to Thread
Results 1 to 11 of 11

Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

  1. #1
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Hi everybody,

    My first post here. Hoping it will yield some success.

    - In Row B I have a list of stock items by their full name. For simplicity, let's use groceries as an example. In Cell B1 "Apples - Red"; Cell B2 "Oranges"; Cell B3 "Apples - Green".
    - In Row A I want to affix a stock code to each item which consists of 8 digits; the first four digits are to be letters (specifically the first four letters of the item to which the code relates) and the suffix will be 4 numbers.
    - In generating the first half of the stock code I am using the formula "=LEFT(A2,4)" but in some instances the first four letters will be the same because the descriptions are similar, so I want the suffix to be the variable in this instance.
    - Taking the example above, Cell A1 will show "APPL", A2 "ORAN" and A3 "APPL". As cell A1 will be the first cell to use the prefix "APPL" I want Excel to automatically detect this and assign the suffix "0001" so that Cell A1 shows "APPL0001". Similarly Cell A2 will show "ORAN0001". But as Cell A3 will also use the prefix "APPL" I want an automatic increment of 1 to indicate that Cell A3 is the second cell to use this prefix. So Excel will generate the stock code "APPL0002"

    Thanks in advance for any help.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,945

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    In A1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    BSB

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,057

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    If your data start in B1 use this in A1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Never use Merged Cells in Excel

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,945

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Great minds think alike, Zbor!

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,057

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    so does excel ones

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Just to be slightly different.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Thanks to everyone who contributed. That's worked perfectly. I've tried to add to all of your reputations but it doesn't seem to have done anything when I click on the *. Don't know if that's anything to do with me being new?

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,057

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Quote Originally Posted by jason.b75 View Post
    Just to be slightly different.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This wont work after 10000

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Quote Originally Posted by zbor View Post
    This wont work after 10000
    Given that the requirement states a 4 digit suffix, neither will yours.

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,057

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Actually it will. Formating cell 0000 will give 0's for less than 10000 but keep full number after that.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to automatically increase 4 digit suffix if 4 digit prefix is same as another

    Quote Originally Posted by zbor View Post
    Actually it will. Formating cell 0000 will give 0's for less than 10000 but keep full number after that.
    My point exactly, 10000 would be a 5 digit suffix, the stipulation was 4 digits.

+ 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] Color a single digit in a mult-digit number cell
    By Phyllis in forum Excel General
    Replies: 8
    Last Post: 09-30-2022, 04:22 PM
  2. Macro to identify 3-digit and 4-digit numbers as valid dates
    By gojakie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2015, 08:16 AM
  3. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  4. Using CONCATENATE and need to increase last digit by 1
    By FunkyDragon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2011, 04:41 PM
  5. Replies: 2
    Last Post: 06-17-2010, 08:36 PM
  6. Calculate to find a suffix digit
    By ElmerS in forum Excel General
    Replies: 18
    Last Post: 05-18-2010, 11:17 AM
  7. [SOLVED] entering 16 digit number in Excel suffix 0 comes automatically
    By Ravi Mohan Sahay in forum Excel General
    Replies: 2
    Last Post: 06-18-2005, 04:05 PM

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