+ Reply to Thread
Results 1 to 19 of 19

Create different repeating numbers

  1. #1
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Create different repeating numbers

    I created a formula that gives me codes by taking the first letters of one column and the last 3 numbers of other column. Though sometimes it give me the same code.
    When it gives me the same I want to add "-1", "-2", "-3", etc. So the code should look like
    CAM456, CAM456-1, CAM456-2.
    Therefore I am looking for a formula that can detect that the new code is the same as previous one and automativally it adds in the new code a "-1", "-2" etc.
    Anybody knows how to do that?
    Last edited by pansovic; 10-15-2011 at 09:12 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create different repeating numbers

    Could this sample work...
    Attached Files Attached Files
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    This is very cool though my origenal formula is a bit more complicate because it consist of 1 condition though if that condition is not valid it takes another data for making the code.
    You can see it in your attached file. I have used your formula from line 9 to 29 and works perfectly though it doesn't give me the right number in line 30 where it has to be "WOC616" and with your formula it gives me "WOC-1". This is because in column G there is no value and when there is no value I have to use other data. My origenal formula you can find in cell A30 and than you will see how it works.
    Question is now how can I integrate my origenal formula in your's?
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    This formula will create the invoice if the cell in column "G" is not empty. I use a helper column "I" with this formula:
    =LEFT(E9,3)&RIGHT(G9,3)
    Add this formula to column "A":
    =IF(G9<>"",IF(COUNTIF($I$9:$I9, LEFT(E9, 3)&RIGHT(G9,3))>1,LEFT(E9,3)&RIGHT(G9,3)&"-"&(COUNTIF($I$9:$I9, LEFT(E9, 3)&RIGHT(G9,3))-1),LEFT(E9,3)&RIGHT(G9,3)),"")
    Last edited by Leith Ross; 10-15-2011 at 07:09 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    Thisn does not add the -1, -2, -3 etc and when there is no value in colomn G it gives me in column A an empty value. This is not the solution.
    JeffreyBrown has the correct formula though I am still figuring out how to integrate my formula into his formula.

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create different repeating numbers

    Quote Originally Posted by pansovic View Post
    I have used your formula from line 9 to 29 and works perfectly though it doesn't give me the right number in line 30 where it has to be "WOC616" and with your formula it gives me "WOC-1".
    Looking at your attachment, A30 reads WOC616 and that is what you say you want.

    If this is not what you want then can you right out your requirements instead of just the formula. More description is required please...

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    Are you sure you followed my directions correctly?

  8. #8
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    This is on reply to Jeffreybrown:
    Cell A30 is written my formula and that's why it gives "WOC616". In cell A29 is used your formula. If you copy your formula to A30 than you will get result "WOC-1"

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    How do you create WCO616 when there is no invoice number in G30? In the copy I downloaded G30 is blank.

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create different repeating numbers

    If I copy the formula down to A30 from A29 in your attachment it shows WOC616.

  11. #11
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create different repeating numbers

    Hi Leith,

    The OP is getting WOC616 from B30 since G30 is blank. The month and day of the date

  12. #12
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    Are you sure you followed my directions correctly?
    OK, now I have used your formula in the Book1 excel file (before I used in my origenal file) and in Book1 file indead is working the -1,-2,-3 Though in the cell A30 it is still empty while it has to be WOC616

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello Jeff,

    Thanks for solving that mystery. I must have missed that piece of information along the way. The First IF statement can be adjusted easily enough to fill that in.

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    Here is the adjusted formula for column "A".
    =IF(G9<>"",IF(COUNTIF($I$9:$I9, LEFT(E9, 3)&RIGHT(G9,3))>1,LEFT(E9,3)&RIGHT(G9,3)&"-"&(COUNTIF($I$9:$I9, LEFT(E9, 3)&RIGHT(G9,3))-1),LEFT(E9,3)&RIGHT(G9,3)),LEFT(E9,3)&RIGHT(G9)&MONTH(B9)&DAY(B9))

  15. #15
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    Quote Originally Posted by jeffreybrown View Post
    If I copy the formula down to A30 from A29 in your attachment it shows WOC616.
    Indeed you are right though in my file still it is not working and I found out why. See now attached Book1 and I have added another line and than I get WOC-1. If following line is blank than indeed your formula is working.
    Attached Files Attached Files

  16. #16
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create different repeating numbers

    Please try Leith's suggestion as it will get you were you need to be...

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    I have attached the workbook with the macros added in.

  18. #18
    Forum Contributor
    Join Date
    05-19-2009
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2019
    Posts
    212

    Re: Create different repeating numbers

    Quote Originally Posted by Leith Ross View Post
    Hello pansovic,

    I have attached the workbook with the macros added in.
    Really looks cool though still have 1, in fact new, problem.
    Attached you can find your file though now I have added new lines and cell A41 should give me "AFP73-1".
    This is same case as WOC (without value in column G) but it is repeating the same code.

  19. #19
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create different repeating numbers

    Hello pansovic,

    Here are the new formulae. Column "A" is now:

    =IF(COUNTIF($H$9:$H9,H9)>1,H9&"-"&(COUNTIF($H$9:$H9,H9)-1),H9)
    Column "H"is now:

    =IF(G9<>"",LEFT(E9,3)&RIGHT(G9,3),LEFT(E9,3)&MONTH(B9)&DAY(B9))
    The attached workbook contains the changes.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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