+ Reply to Thread
Results 1 to 11 of 11

Counting names within a cell

  1. #1
    Registered User
    Join Date
    10-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Counting names within a cell

    Hi,

    I have many rows of data formatted in the following way within each cell.

    43598: Joe Bloggs
    38768: John Smith
    97568:
    87231: John Smith


    I would like to count the number of times in each cell that a reference number appears but no name is present next to it (i.e. 1 in the above example). The result can appear in a seperate column next to the data.

    I would assume this is something that could be done with counting the length between carriage returns and/or related to the colons after the reference numbers, unfortunately my excel skills have not come up with a solution and I have not found anything similar enough by searching.

    If this is possible, I am not bothered whether I end up using a cell formula or VB code.

    thanks in advance.
    Last edited by tackit; 10-19-2010 at 04:51 PM. Reason: Solved

  2. #2
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Counting names within a cell

    Are all reference numbers the same length? That is 5 characters as per your example?

    If so, do you want to show a total in some sort of row beneath all the data column, or do you want excel to show a 1 right beside each entry?

    Try this in the mean time (solution without VB).

    Insert a column right beside your data, assuming your data is on A1:A100, insert a column after that and insert the following formula in B1=IF(LEN(A1)>=7,0,1) and drag up to B100
    Then you place the sum of B1:B100 anywhere you want and then hide column B. Naturally you will not put the sum in column B, otherwise it'll be hidden.
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  3. #3
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Counting names within a cell

    Try:

    Please Login or Register  to view this content.
    Entered with Ctrl-Shift-Enter (CSE)

    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  4. #4
    Registered User
    Join Date
    10-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Counting names within a cell

    Hi,

    Thanks both for the response unfortunately I have not explained properly. The example above is typical of 1 cell. There may be any number of references and associated names in a cell (including 0). I am likely to have hundreds of rows with anything between 0 and 20 sets of ref and name in each but with numerous occasions where the name is missing.

    The ref numbers are always 5 digits and I would like to see the result for each cell to the right, I.en. column B.

    Thanks again.

  5. #5
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Counting names within a cell

    Quote Originally Posted by tackit View Post
    Hi,

    I have many rows of data formatted in the following way within each cell.

    43598: Joe Bloggs
    38768: John Smith
    97568:
    87231: John Smith


    I would like to count the number of times in each cell that a reference number appears but no name is present next to it (i.e. 1 in the above example). The result can appear in a seperate column next to the data.

    I would assume this is something that could be done with counting the length between carriage returns and/or related to the colons after the reference numbers, unfortunately my excel skills have not come up with a solution and I have not found anything similar enough by searching.

    If this is possible, I am not bothered whether I end up using a cell formula or VB code.

    thanks in advance.
    are the reference numbers unique? ie, will 12345 be in more than 1 cell and if so do you want that counted as say 2 seperate instances of a number, or the total number of times for 12345 =2

    I just had another thought, is the cell containing 20 sets of names and numbers got carriage returns? if you stretch say A1 with your example out longways, does the text still stack one on top of the other or is it turning into 1 long line of names and numbers?
    Last edited by scottylad2; 10-18-2010 at 08:13 PM.

  6. #6
    Registered User
    Join Date
    10-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Counting names within a cell

    Hi,

    The ref numbers are unique for the entire column of data and are always 5 digits.

    The cell has carriage returns, if I remove wrap text it shows the square symbols between each ref and name.

    Thanks

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting names within a cell

    I can't emphasise enough how useful a sample file would be at this stage...

    If there is some consistency regards position of carriage return and last char on that line it may be that you can conduct some comparisons between position of colon and carriage return.

    Seeing is believing etc...

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting names within a cell

    Just to elaborate on my thinking - using the samples:

    Please Login or Register  to view this content.
    where A1 contains the string of interest - assumes a space always follows colon (even if "name" is empty)

  9. #9
    Registered User
    Join Date
    10-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Counting names within a cell

    Ok thanks,

    Am only on mobile at the moment so unable to post a file but will do later on tonight.

    Cheers

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting names within a cell

    In retrospect - further to prior suggestion the below alternative makes more sense:

    Please Login or Register  to view this content.
    similar premise as before

  11. #11
    Registered User
    Join Date
    10-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Counting names within a cell

    Quote Originally Posted by DonkeyOte View Post
    In retrospect - further to prior suggestion the below alternative makes more sense:

    Please Login or Register  to view this content.
    similar premise as before

    Hi,

    This worked a treat.

    Many thanks for all the replies.

+ 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