+ Reply to Thread
Results 1 to 6 of 6

Formula to look for matching numbers & add -1, -2, -3 respectively

  1. #1
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Formula to look for matching numbers & add -1, -2, -3 respectively

    Hi all,

    Does anyone know of a formula I can put into a column that will add -1, when the same number is entered & -2 when the number is entered again & so on?
    e.g.

    1
    2
    3
    1-1
    4
    5
    1-2
    6
    2-1

    As always thanks for any assistance guys - Marco

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Formula to look for matching numbers & add -1, -2, -3 respectively

    Do you want this done with a macro, or with a formula in an adjacent column?

    =IF(COUNTIF($A$1:A1,A1)-1=0,A1,A1&"-"&COUNTIF($A$1:A1,A1)-1) will give you the results you want if you enter the formula in Column B and copied down.

    I hope this helps, please let me know!

    Regards,

    David


    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  3. #3
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Formula to look for matching numbers & add -1, -2, -3 respectively

    Hi David,

    working great but on the next blank cell in Column A it repeats "--1" in column B instead of leaving it blank? Thank you, really appreciate your help David! - Marco

  4. #4
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Formula to look for matching numbers & add -1, -2, -3 respectively

    Hi Marco,

    All you need is an extra test for a BLANK cell, like this:

    =IF(A1="","",IF(COUNTIF($A$1:A1,A1)-1=0,A1,A1&"-"&COUNTIF($A$1:A1,A1)-1))


    Regards,

    David


    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  5. #5
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Formula to look for matching numbers & add -1, -2, -3 respectively

    Hi David,
    Works like a charm, thanks for your help! - Marco

  6. #6
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Formula to look for matching numbers & add -1, -2, -3 respectively

    You're welcome Marco.

    DAC

+ 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] Matching a duplicate row of numbers in a list of numbers in rows
    By sgrondines in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-18-2015, 09:24 AM
  2. Replies: 2
    Last Post: 05-02-2015, 10:49 AM
  3. Replies: 3
    Last Post: 11-03-2014, 04:23 PM
  4. [SOLVED] formula to sum numbers based off of single or matching dates
    By nicki_rae22 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-21-2014, 01:24 PM
  5. [SOLVED] Assign incremental numbers to matching Invoice numbers
    By berger01 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 10:54 AM
  6. Replies: 2
    Last Post: 03-13-2012, 07:01 PM
  7. Deleting rows matching numbers from numbers in column
    By cyki in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-11-2008, 09:16 AM

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