+ Reply to Thread
Results 1 to 10 of 10

Assign a letter based on the total count

  1. #1
    Registered User
    Join Date
    11-03-2015
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    13

    Assign a letter based on the total count

    Problem:
    I have a column of names ending with a total count of entries that can range, let's say 10-75, and I would like to assign a 5 letters to a new column evenly and preferably in order top down.
    So what I have:
    A B
    1 Matt
    2 Mark
    3 Chris
    4 Nate
    5 Jake
    6 Bill
    7 Hank
    8 Will
    9 Jack
    10 Jose
    100 10

    What I want:
    A B
    1 Matt S
    2 Mark S
    3 Chris H
    4 Nate H
    5 Jake A
    6 Bill A
    7 Hank R
    8 Will R
    9 Jack K
    10 Jose K
    100 10

    If I had 75 entries each letter of "S H A R K" would represent 15 names and so on.... I would prefer this to be a function only, no macros.

    Thanks for any help!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,440

    Re: Assign a letter based on the total count

    Will the number of names always be a multiple of the number of characters in your word? If not, then the last letter will be used a fewer number of times.

    Is the work SHARK fixed, or will you want to be able to change that easily?

    Pete

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

    Re: Assign a letter based on the total count

    With 'SHARK' in C1, enter this in B1 and copy down

    =MID(C$1,INT((ROWS(A$1:A1)-1)/(COUNTIF(A:A,"> ")/LEN(C$1)))+1,1)

    This is based on your example, it will need adjusting if you have column headers.

  4. #4
    Registered User
    Join Date
    11-03-2015
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    13

    Re: Assign a letter based on the total count

    Thank you for the speedy response!

    Could I request to see that as A1:A99 as a range rather than a column?

    As my example is its own sheet, my actual data is in a large data sheet ie Q85:Q184 but not exact as I am currently away from my PC and at work.

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

    Re: Assign a letter based on the total count

    Sure, I've moved it based on your example range of Q85:Q184, 'SHARK' in S85, this formula in R85 and copied down.

    =MID(S$85,INT((ROWS(Q$85:Q85)-1)/(COUNTIF(Q$85:Q$185,"> ")/LEN(S$85)))+1,1)

    The range can be larger than needed so you don't need to edit if you add or remove names from the list, it will ignore blanks or numbers (at the bottom of the list, but not the top or middle).

  6. #6
    Registered User
    Join Date
    11-03-2015
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    13

    Re: Assign a letter based on the total count

    I look forward to applying this tonight when I get home! Thank you! So just so I understand this doesn't require the use of the total cell at the end of the column?

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

    Re: Assign a letter based on the total count

    No, the total cell is not used, the COUNTIF part of the formula takes care of that.

    One point that would need to be addressed to ensure accuracy was mentioned by Pete_UK in post #2.

    Assuming use of the word 'SHARK', how should the letters be allocated if you have (for example) 21,22,23 or 24 names in the list?

  8. #8
    Registered User
    Join Date
    11-03-2015
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    13

    Re: Assign a letter based on the total count

    Very good, I'll let you know if I run into any snafu as I try the various data I try to run through.

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

    Re: Assign a letter based on the total count

    Quote Originally Posted by Dragonphantom View Post
    I'll let you know if I run into any snafu as I try the various data I try to run through.
    Please do, snafu and fubar frequently inspire new methods and ideas

  10. #10
    Registered User
    Join Date
    11-03-2015
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    13

    Re: Assign a letter based on the total count

    Works like a dream! Thank you very much. :D

+ 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. VBA - Assign value for each letter and sum it.
    By janagan in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-20-2018, 02:06 AM
  2. [SOLVED] Assign a number to a letter
    By kevincoxshall in forum Excel General
    Replies: 5
    Last Post: 08-14-2013, 11:59 AM
  3. [SOLVED] Count Total Day Based On Date
    By redza in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-22-2013, 02:52 PM
  4. [SOLVED] Assign Letter from list based on two conditions.
    By stockgoblin42 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-22-2013, 04:10 PM
  5. Count total based on condition.
    By Gauntsghost in forum Excel General
    Replies: 4
    Last Post: 01-18-2010, 09:36 PM
  6. Count based on letter designations and dates
    By Karleajensar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-08-2007, 10:11 AM
  7. Assign numerical value to letter.
    By Micke_M in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 05-26-2007, 04:00 PM
  8. How do I assign a letter to a weekday
    By alexbutterfield in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-02-2007, 10:30 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