+ Reply to Thread
Results 1 to 11 of 11

[SOLVED] Conditionally collect data in one cell?

  1. #1
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17

    [SOLVED] Conditionally collect data in one cell?

    Hello there,

    I'm trying to make a spreadsheet that looks up values for a number of individuals and if they meet certain criteria they are collected in a box.

    It is for a class of children's test results. I would like to be able to write the results each child got across the page (names at side, headings across top). If a child gets, say, level 2a in his test, his name appears in a cell elsewhere. I can do this with an 'IF' statement... Thing is I want to collect all the children who got that level in the other cell. The cell might end up with 10 or 12 names in it as a result of their scores being looked up. I would have cells for all of the levels, so the children can be automatically grouped together by attainment.

    This is rather beyond my capabilities! Is it doable - and if so, can anyone help?

    Thanks very much in advance!

    Steve
    Last edited by GenieNitro; 11-13-2008 at 08:59 PM.

  2. #2
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17

    Question Partial solution?

    Hi, I've figured a way of nearly getting what I want... I think its a bit long winded though...

    this is what I've done:
    =IF(B11="2b",A11&" ","")&IF(B12="2b",A12&" ","")&IF(B13="2b",A13&" ","")&IF(B14="2b",A14&" ","")&IF(B15="2b",A15&" ","")&IF(B16="2b",A16&" ","")&IF(B17="2b",A17&" ","")&IF(B18="2b",A18&" ","")&IF(B19="2b",A19&" ","")

    Seems to work!

    Now - is it possible to add up the number of names that appears in this cell and send the answer to another cell?

    cheers

    Steve
    Last edited by GenieNitro; 11-13-2008 at 05:24 PM.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Please Login or Register  to view this content.
    Change the cell reference to where your names are collecting.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    And a slight aesthetic adjustment to your code, puts in a comma and space and adds it ahead of the name when it's used instead of after. For your consideration:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17
    Quote Originally Posted by JBeaucaire View Post
    And a slight aesthetic adjustment to your code, puts in a comma and space and adds it ahead of the name when it's used instead of after. For your consideration:
    Please Login or Register  to view this content.

    Thanks, will try that...

    Actually, my code has come up with a bit of a problem.
    The data this code is reading is actually on a different worksheet (at the beginning of the workbook). The code has come out so long that I can only get it to address 28 students before the 'formula is too long'. Unfortunately, our classes sometimes go above 30 (maybe to 32/33). Any way of trimming the length a bit? (A have already changed the name of the data worksheet to simply '1' but it's still too long!

    cheers

    Steve

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    I was wondering about that as I read it. You need a souped up version of the Concatenation function. You'll have to create it. The benefit of creating your own UserDefinedFunction is you get some new powerful and short tools for concatenating a large string of data.

    CPearson has written a UDF called StringConcat that you can access the code for here:
    http://www.cpearson.com/excel/StringConcatenation.aspx

    Follow the instructions CAREFULLY for getting that UDF into your sheet.

    Once it's in, your new formula would be much simpler. Let's say your 30 kids names are all in A2:A31 and the "2d" flags are in C2:C31, your new code would simply be:
    Please Login or Register  to view this content.
    This is an array formula, so you have to press CTRL-SHIFT-ENTER instead of just ENTER. Is that short enough for you? Hehe.

    Good luck!
    Last edited by JBeaucaire; 11-13-2008 at 07:07 PM.

  7. #7
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17
    Thanks for that!

    HAve to say - ooerr! Never done anything with visual basic before!

    I downloaded the bas module file but I can't find the instructions on how to include it in my spreadsheet... Probably being a bit thick!

    Steve

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    How to Create Excel User Defined Functions

    No, follow these instructions on the page for manually inserting it. The code is there, just cut and paste. Everything between Function StrongConcat and all the way down to End Function. Here you go:

    How to Create Excel User Defined Functions
    1. Open up your workbook.
    2. Get into VBA (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste the your code
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet.
    7. Use the functions (They will appear in the Paste Function dialog box, Shift+F3, under the "User Defined" category)
    If you want to use a UDF in more than one workbook, you can save your functions in your own custom add-in. Simply save your excel file that contains your VBA functions as an add-in file (.xla). Then load the add-in (Tools > Add-Ins...).

    Warning! Be careful about using custom functions in spreadsheets that you need to share with others. If they don't have your add-in, the functions will not work when they use the spreadsheet. Best to store those UDFs in the sheets themselves.

    (Source)

  9. #9
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17
    Thanks soo much! That's working nicely!

    Steve

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Awesome. Don't forget to mark this question SOLVED. (Edit original post and click SOLVED in the box to the left of your title.)

  11. #11
    Registered User
    Join Date
    11-13-2008
    Location
    London
    Posts
    17
    For some reason I can't see the little solved box (Firefox on OSX) so have added it manually!

    Steve

+ 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