Results 1 to 4 of 4
  1. #1
    analarana is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    2

    the cells that some rows have in common


    Hi,
    I know nothing about access, and I don't even know if access is the right program for what i need.

    Could someone please tell me how I can find the cells that some rows have in common? I need to do this lots of times with lots of names, but this is a small example:
    excel2.jpg
    So for example, the first time I need to know the numbers that Ana (row 1), Laura (row2) and Manuel (row3) have in common, so the computer should give me nš17 as the answer. If I ask for the numbers (or cells) Chris (row 4)and Eddie (row 5) have in common, the computer should say nš2, nš3 and nš4. I'm not looking for the number that appears more times in the grid, but for the one that the rows I select have in common.
    Cheers.
    Click image for larger version. 

Name:	excel2.jpg 
Views:	19 
Size:	110.3 KB 
ID:	12675

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Sure, Not Hard

    This can be done in Access, and it's not too difficult. You would store each of those lines as several rows in the same table, like this:

    Code:
    tbl_PN
    Pers   Num
    Ana     1
    Ana     5
    Ana    17 
    Ana    21
    Ana    13
    Ana    35
    Laura   2
    Laura   4
    Laura   1
    Laura  17
    Laura   3
    Laura   9
    Manuel 37   etc
    Then, you would code a query something like this:
    Code:
    SELECT Num, COUNT(*)
    FROM tbl_PN
    WHERE (Pers = "Ana" OR Pers = "Laura" OR Pers = "Manuel")
    GROUP BY Num
    HAVING COUNT(*) = 3;
    That query gets you all the Numbers that have been chosen by those three people.

    Once that is working, you could build a form that allows you to pick the three people, and builds and runs the query for them.

    If you wanted all possible combinations of three people, I'd probably design a trickier way, based on number theory, but this one would work for any one combination of three.

  3. #3
    analarana is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    2
    Cool, thanks a lot. I’ll have to learn a bit of access to fully understand your explanation.
    So should I put all the names on the first column and all the numbers on the 2nd one?
    Also, would this query work if the names have more than 1 number in common (would the computer give more than one number as a result)?
    Thanks again.

  4. #4
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    To answer your last question first - that query will get every number that the three people have in common. You could change the "= 3" to "= 2" and you'd get every number that exactly two of the three had in common.

    In this table, for this code, each person gets one record per number, so they would each have six records.

    What you can do, is leave the worksheet the way you have it, and when you import the worksheet, using Access's import wizard,

    1) import it into a temporary table tblTempNums (tname tnum1 tnum2 tnum3 tnum4 tnum5 tnum6).

    2) delete all the data out of your real table. Just to be clear, the first time you have to create the empty table tbl_PN with the two fields Pers and Num, and you won't have to delete the data.

    DELETE * from tbl_PN;

    3) create an append query for each column from the temp table. The code for the first two queries would look something like these (you'll create all six):

    INSERT INTO tbl_PN
    (Pers, Num)
    VALUES
    (SELECT tname, tnum1 FROM tmp_TempNums);

    INSERT INTO tbl_PN
    (Pers, Num)
    VALUES
    (SELECT tname, tnum2 FROM tmp_TempNums);

    4) run the delete query and all those append queries each time you need to import the workbook fresh.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to unite cells with common data?
    By roeebicher in forum Queries
    Replies: 0
    Last Post: 02-07-2013, 05:11 AM
  2. Combine datatable rows based in common value
    By pipelian in forum Access
    Replies: 1
    Last Post: 11-27-2012, 10:20 AM
  3. code to delete rows based of empty cells
    By jcbrackett in forum Programming
    Replies: 3
    Last Post: 03-05-2012, 02:27 PM
  4. Columns, Rows & Cells
    By Paul H in forum Reports
    Replies: 7
    Last Post: 09-21-2011, 12:27 PM
  5. Replies: 7
    Last Post: 09-15-2011, 01:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums