+ Reply to Thread
Results 1 to 32 of 32

Add letters to numbers in column "B"?

  1. #1
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Question Add letters to numbers in column "B"?

    Hello,
    I have a list in column”A” with 5 number in each cell,in column “B” I would like to add letters to each cell
    From six letters only (A:F) ,but each letter to be used with any numbers in column “A” only once.is there any way to do this with excel formula in column “B”? the list is below;
    Thank you for any suggestion,
    Sem,

    1 2 3 4 5 A
    1 6 11 16 21 B
    1 7 13 19 25 C
    1 8 15 17 24 D
    1 9 12 20 23 E
    1 10 14 18 22 F
    2 6 15 19 23
    2 7 12 17 22
    2 8 14 20 21
    2 9 11 18 25
    2 10 13 16 24
    3 6 14 17 25
    3 7 11 20 24
    3 8 13 18 23
    3 9 15 16 22
    3 10 12 19 21
    4 6 13 20 22
    4 7 15 18 21
    4 8 12 16 25
    4 9 14 19 24
    4 10 11 17 23
    5 6 12 18 24
    5 7 14 16 23
    5 8 11 19 22
    5 9 13 17 21
    5 10 15 20 25
    6 7 8 9 10
    11 12 13 14 15
    16 17 18 19 20
    21 22 23 24 25
    Last edited by sem; 03-03-2011 at 07:13 AM.

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    Maybe this:

    =B11&CHOOSE(MOD(ROW(),6)+1,"A","B","C","D","E","F")

    Depending on the starting row (and if you want the first cell in B col to have the "A" attached) you can change the order of the letters within the CHOOSE() to suit. As is, the "A" will attach to rows 6, 12, 18 etc

  3. #3
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Question Re: Add letters to numbers in column "B"?

    Hi cutter,
    thanks for your response,
    the formula almost there,but it needs some adjustment.
    instead of "B11" ;"B1" and also say first cell is "A" then A should not be used with "1;2;3;4;5" again every letter to be used with any numbers in column"A" once.
    i hope i cleared for you.
    thanks again
    Kind regards

  4. #4
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Question Re: Add letters to numbers in column "B"?

    hi,
    i tried the formula unfortunately it does not give right result,if letter"A" start with first row
    1 2 3 4 5,next should be with 6......,11....,16....21...as isaid before every letter should be used with every number once only.maybe it needs VB code??
    any help would be appreciated.

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    Sorry, I totally misunderstood what you were looking for. I don't know, offhand, how to accomplish what you want.

  6. #6
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Cutter,
    thanks for your effort, atleast you gave something....much appreciated.
    so is there any one have some suggestion please???
    Regards

  7. #7
    Registered User
    Join Date
    12-28-2009
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Add letters to numbers in column "B"?

    Hi

    a slight change to Cutter's formula

    Please Login or Register  to view this content.
    Osvaldo

  8. #8
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Osvaldo, thanks for your help.
    this formula also giving same result as Cutter's.
    if you notice there are 1-25 numbers been used in the list what it need is for each letter to be used with every number once only.example of your formula result ;
    1 2 3 4 5A; 2 6 15 19 23 A; 3 7 11 20 24 A ; 4 8 12 16 25 A; 5 9 13 17 21 A
    number 2 and 5 used twice .if they have been used once then it is correct result.
    anyhow thanks for your effort.
    ragards

  9. #9
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    hi osvaldo,
    thanks for the message the right result for letter"A" is;
    1 2 3 4 5 A ; 6 7 8 9 10 A ; 11 12 13 14 15 A ; 16 17 18 19 20 A ;21 22 23 24 25 A
    if you notice all numbers 1-25 are all covered,so it should be the same with the remaining "B to F" letters.
    I think VB code would sort it better than excel formula.But how??
    Regards
    Last edited by sem; 02-18-2011 at 12:14 PM.

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    Are you saying the first number in the string of 5 numbers in each cell is the only one that determines what letter is used?

    And that first number is never more than 25?

    So the second time a 1 appears in the first position the attached letter is a B, third time is a C, etc up to 6th time is an F? And the same for all other 24 numbers?
    Last edited by Cutter; 02-18-2011 at 12:28 PM.

  11. #11
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi Cutter,
    Thats right first number is never more than 25.and also the first number in the string of 5 numbers and what other numbers in cell that determines what letter and number is used.lets look to next row which is; 1 6 11 16 21 B ; so next row should start with num.2 but not contain numbers “6 11 16 or 21” ; 2 7 12 17 22 B ;next row should start with num 3 ,but not contain numbers from the first 2 rows and continue with rest of the all letters.
    I hope this help to clarify to solve the problem.
    regards

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    So, in actual fact you aren't only asking for a method to attach the appropriate letter but for a method to arrange the numbers as well. Is that correct?

  13. #13
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi,
    I’m only asking for method to attach the appropriate letters to the list in column “A” with the criteria
    I explained in my previous post,you arrange the letters so each letter used 5 times(rows) and in those 5 rows must contain all 1 to 25 numbers in it.
    Thanks for your time and help..
    regards

  14. #14
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    OK, one last stab at trying to understand this one.

    With your sample list (shown in original post) occupying col A starting in row 1

    Use this helper column in B (or whatever - I used B)
    In B1 and dragged down:
    =LEFT(A1,2)*1

    In C1 this:
    =A1&" A"

    In C2 and dragged down:
    =A2&" "&CHOOSE(COUNTIF(B$1:B2,B2),"A","B","C","D","E","F")

  15. #15
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi,
    thanks for the formula but unfotunately still not giving the result.
    every letter suppose to be used 5 times and each letter to be attached to rows contain
    numbers from "1 to 25" here is your formulas result;
    1 2 3 4 5 A
    1 6 11 16 21 B
    1 7 13 19 25 C
    1 8 15 17 24 D
    1 9 12 20 23 E
    1 10 14 18 22 F
    2 6 15 19 23 A
    2 7 12 17 22 B
    2 8 14 20 21 C
    2 9 11 18 25 D
    2 10 13 16 24 E
    3 6 14 17 25 A
    3 7 11 20 24 B
    3 8 13 18 23 C
    3 9 15 16 22 D
    3 10 12 19 21 E
    4 6 13 20 22 A
    4 7 15 18 21 B
    4 8 12 16 25 C
    4 9 14 19 24 D
    4 10 11 17 23 E
    5 6 12 18 24 A
    5 7 14 16 23 B
    5 8 11 19 22 C
    5 9 13 17 21 D
    5 10 15 20 25 E
    6 7 8 9 10 A
    11 12 13 14 15 A
    16 17 18 19 20 A
    21 22 23 24 25 A

    i think it need VB code?
    regards

  16. #16
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Add letters to numbers in column "B"?

    I think it needs you to supply a sample file with what you want - clearly showing the results you expect and why.

    As they say on Dragon's Den - I'm Out.

  17. #17
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi Cutter,
    you did what you can,
    Thanks for your time and effort.....much appreciated,
    regards

  18. #18
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Bump......

  19. #19
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    Try this workbook.

    This is only draught code using helper columns and VBa.
    If it returns the expected result, then we can tidy it up a bit and get rid of the helper columns
    Please Login or Register  to view this content.

    Run the macro "GradeAtoF"

    Hope this helps
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  20. #20
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi Marcol,
    thanks for your time and effort,
    the code works great you're A Genius..... thanks a mill. would it be possible to use it in different list and with out helper column.
    if i may ask how did you post the attachment file?
    i could not open the macro will not allow me unless i enable the macro,i used new
    workbook to try your code.
    thanks and God Bless...
    sem

  21. #21
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    1/. The easiest, and possibly the fastest way to eliminate the helper columns is not to!
    We can "cheat" by adding 6 extra columns after Column B (this should not affect anything else on that worksheet), run the adjusted code, then Delete these added helper columns.
    Please Login or Register  to view this content.

    What do you mean by a different list?


    2/. I used the forum facilities to upload the file and there doesn't seem to be a problem opening it.
    See Forum Rules
    Want to get your question answered quickly?

    Did you enable macros when you opened the file? You must do so to make the code work.
    Attached Files Attached Files

  22. #22
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    hi Marcol,
    thanks for the help ....much appreciated.
    i think i'm going to keep helper columns but instead of vertically could i have them horizontaly,and suppose i used different list with more letters which part of the code do i need to change inorder to get the right result. say 19 letters and they are going to be used 13 times each but with the same principal, would the code work ???
    i attached the exl book i hope its ok.
    also instead of letters would it be possible to have numbers,and what change have to be done to accomodate the numbers??
    regards
    Attached Files Attached Files

  23. #23
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    Hmm?

    Some more rules have changed

    For this to work the sheet will have to be formatted
    Select the whole sheet and Format Cells > Number > Custom
    Type:=
    Please Login or Register  to view this content.
    Then use this code.........
    [EDIT]
    Somehow posted an earlier version of the code, probably forgot to save the correct version.
    This has now been "corrected" and expanded in Post#27.
    Code and attachment removed to avoid further confusion.
    [End EDIT]
    ......Run macro "Sub GradeFromAtoWhat" with the required last letter.

    This should give you the horizontal Table of used numbers A to Whatever.

    We can worry about using Numbers instead of Letters later.

    How about a bit of quid pro quo?
    What is the purpose of this exercise? What is it analysing?
    Last edited by Marcol; 02-28-2011 at 08:31 AM. Reason: Errors in code, attachment removed

  24. #24
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi Alistair,
    As ever thanks for for your time and great help,much appreciated.
    This work not for analysing its like Jigsaw Puzzle but with numbers and instead of looking for jigsaw
    piece ,we look for rows in the list to solve the problem by completing the row or columns to specific
    numbers like the list we solved ,it’s got “1 to 25” for each letter,”A to F”.i hope i explained myself..!
    in the code it’s only up to letter”F” input ,do i need to increase if more letter needed like;
    Dim NoFoundE As Boolean, NoFoundF As Boolean
    >>>>>>>>>>>TO
    Dim NoFoundG As Boolean, NoFoundH As Boolean
    >>>>>>>>>>
    NoFoundF = IsNumberInRange(Columns("H:H"), arrTemp)
    >>>>>>>>>>>TO
    NoFoundG = IsNumberInRange(Columns("I:I"), arrTemp)
    >>>>>>>>>>>>
    Case NoFoundF
    AppendToFoundList 8, arrTemp
    Range("B" & RowNo) = "F"
    >>>>>>>>>>>>>>TO
    Case NoFoundG
    AppendToFoundList 8, arrTemp
    Range("B" & RowNo) = "G"


    How many row start with number “1” dictate how many letters we are going to use,in Sheet 1 on the attachment is the right result;in sheet 2 different list but same amount of rows but i did not get the right result ???in Sheet3 for each letter should start with “1” using all rows with number”1” but somehow they are not am i doing something wrong???in Sheet 5 should not be a column”T” i put thick lines to see more clear if all rows been used all columns missing one or more rows but maybe this it can not be solved?
    Thanks again for your effort,
    Kind Regards
    Sem
    Attached Files Attached Files

  25. #25
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    Your telling me it's a jigsaw!!!!!
    One where the key bits are missing.
    Do you have a box-lid with a picture on it?

    I will have one more go later tonight, once I have digested your new workbook. For now I'm off for a few beers to see if that will make your problem clearer.... ..

    Look back tomorrow sometime, probably in the evening, say after 19:00 GMT

  26. #26
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    thanks Alistair and i'm sorry for all this trouble,
    i wish i have box lid with all the answers,otherwise i would not bother anyone.
    Have you heard about "Social Golfer Problem" those questions i am asking are all similar to that problem.
    Thanks and God Bless.
    Sem

  27. #27
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    Hmm?

    I made some mistakes in Post #23 hopefully this version will work better, it has been updated to allow for this new, or clarified, rule
    How many row start with number “1” dictate how many letters we are going to use
    Please Login or Register  to view this content.


    Now for the crunch...
    The "Social Golfer Problem"
    That is hopefully not what you are trying to find an answer to, it certainly is not what you have so far asked for.

    In this problem

    01 02 03 04 05
    01 05 03 04 02

    Would give you A, B
    But in the Social Golfer the second line is unacceptable because 02 and 03 appear together, 05 & 02 are in both groups but this can be acceptable depending on the application of the problem, consider Kirkmans' Ladies.

    The more I think of it the more it confuses me, the rules must be clearly stated before any attempt at a solution is attempted.

    If this latest code doesn't give you the result you are expecting, then you are on your own, unless you can clearly define the brief.

    Cheers and good luck
    Alistair
    Attached Files Attached Files
    Last edited by Marcol; 02-28-2011 at 09:30 AM.

  28. #28
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Hi Alistair,
    Thank you very very very much for the new VBcode its better than the first two code,i really appreciate your help.Sheet1 and 3 is perfect ,sheet2,4 and 5 also good but not solved ,in sheet 6,7and8 i get error “type mismatch,Run time error 13 “ and it highlite this line:
    “Do While Left(Cells(RowNo + 1, 1), InStr(1, Cells(RowNo + 1, 1), " ")) * 1 = 1”
    If you could fix Sheet 6,7 and8 i’ll be very happy man,because my curiosity is killing me not the cat!!!!!not knowing if those problems can be solved or not.for years i been trying by pen and paper
    Recently i started to use computer to see if i can solve those problems.
    for your challange is it possible to implement this VB code to full Combin(15,5)and
    Combin(25,5),you don’t have to do it,but is it possible????????
    I can not thank you enough for your invaluable time and help...much appreciated.
    Kind regards and God Bless
    Sem
    Attached Files Attached Files

  29. #29
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    1/. Why have you added leading and trailing spaces to the number strings, and for good measure doubled up the separator spaces?
    That is why the code failed.

    Overwrite all of the code in the last posted workbook with all of this
    Please Login or Register  to view this content.

    2/. You say...
    ....sheet2,4 and 5 also good but not solved.....
    What is not solved?

    3/. Yes VBa can do the combinations you ask about, but you will have to define the parameters before you start, and that would be the subject of a new thread.

  30. #30
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Talking Re: Add letters to numbers in column "B"?

    Hi Alistair,
    If i thank you from here to The Moon will not be enough ....then again i’m over the Moon.....!!!!!!!
    I tried it on over than 50 list it still gives “mismatch error or “”Invalid procedure call or argument error 5”” when i try it on lists over than 1300 combinations ???? even i tryed it on Combin(15,5)and Combin(25,5) it gives same error any idea why???.but this result in this attachement is out of this world ,this how all the lists results should be.thats why i would like to share it with you ,because this isthe result of your Outstanding work....greatly appreciated.
    When i said its not solved in my previous post ,it did not give the same result as the the list in attachment
    Have a wonderful day.....
    Regards
    sem
    Attached Files Attached Files

  31. #31
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Add letters to numbers in column "B"?

    Once again you are changing the rules in this thread.
    Your title states
    Add letters to numbers in column "B"?
    As far as I recall there are 26 letters in the English language alphabet. I therefore made no allowance for the code to run after A-Z had been found, happens that it does run "successfully" but instead of returning letters it returns Ascii characters, this includes a-z and other mystical characters a variety of non printing characters included. This means the code will "fail" initially after 255-65 itterations.

    I can't replicate the error you have found with the last sample provided, and, I'm sorry, have no intention of trying to further do so.

    It is now clear to me that it is the "social golfer problem" that you are fishing for and I refer you to this thread, it might be familiar to you

    01-24-2011, 07:36 PM

    Vb code for meeting arrangement
    http://www.excelforum.com/excel-gene...rangement.html

    Reply from shg - (A snr member of this forum who is no mean mathematician and has a fair degree of understanding of excel to boot.)
    If you read the links, then you read that some very good mathematicians have studied these problems for almost 150 years and solved a few dozen specific ones.

    Try as we might, I don't think we're going to best them.
    Slainte, agus mar sin leibh.
    Alistair

  32. #32
    Forum Contributor
    Join Date
    01-21-2011
    Location
    London,UK
    MS-Off Ver
    Excel 2007
    Posts
    241

    Red face Re: Add letters to numbers in column "B"?

    Alistair ,I’m sorry if i gave indication to seek an answer which i meant not to,but i can assure
    You i have no interest in “Social Golfer problem” at all,the only thing i’m seeking answer to
    Are attachment in post 28, 30 and Combin(15,5);(25,5) which your last Vb code have solved some of them ,and i greatly appreciate for all time and help.the only reason i posted the last attachment is to show you the result of your excellent work and nothing else.
    Thanks again and kind regards
    Sem

+ 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