+ Reply to Thread
Results 1 to 13 of 13

Count the number of items in a column that are equal to another column's #'s in same row.

  1. #1
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Count the number of items in a column that are equal to another column's #'s in same row.

    Hello,

    I have a sheet that has a building. And another sheet that has a bunch of buildings listed in A.

    The second sheet also has a value in column F, and another column of values in E.

    (F is a rental adjustment, and E is what their normal rent is)

    In English, I need to look up a specific building on the first sheet in all of the adjusted rent roll sheet, and count the number of times there is an adjustment (F value) only if the adjustment is for their full rent in column E.

    Example:

    First sheet A4 = building1

    Second sheet


    A4 = Building1 E4 = $469 F4 = $469

    A5= Building1 E4=$175 F4 = $175

    A6= Building1 E4 = $169 F4=$35

    A7=Building2 E4=$450 F4=$450

    The answer in the first sheet should be 2, because a4 and a5 are two adjustments that also equal their original rent in column e.

    Couldn't find anything online about using sumproduct to equal the same row in an array only to equal one specific cell or value.

    Thanks for your help,

    Gabe

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Hi Gabe,

    Please upload a sample workbook.. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Can be done with a user defined function.

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a B4 on Sheet1 enter =GetCount(A4,Sheet2!A4:A7,Sheet2!E4:E7,Sheet2!F4:F7)

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  4. #4
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    sample excel sheet.xlsx

    Thanks dilipandey

    I need the numbers I filled out in sheet1 G to fill in automatically based on sheet2 column G matching the building in sheet1 column A and that it's the same value as sheet2 column F (*-1)

    Hope this helps a little, thanks for your help

    Gabe

  5. #5
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Thanks Martin, If I was dealing with a larger data set I would definitely be interested in a macro; however, I am always getting a new report so I'd have to do this every time. Really surprised this is not included in stock excel, seems like it could be a popular feature.

  6. #6
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Hi Gabe17,

    I think more details required here.. how you are getting sheet 1 G4 as zero and G5 as 1 ?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Pasting the new report into a macro workbook wouldn't take long and would compare favourably with adding a complex formula. A user defined function behaves very much like a stock Excel function.

  8. #8
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    G4 is 0 because sheet2 G16 is equal to $150 and sheet2 F16 is equal to $540 (so not the same so it doesn't count)

    G5 is 1 because sheet2 G20 is $139 (negative, but same absolute value) and F20 is equal to the same amount $139.

  9. #9
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Hi Gabe17,

    Try using below formula:-

    =IF(ABS(VLOOKUP(A4,Sheet2!$A:$G,6,0))=ABS(VLOOKUP(A4,Sheet2!$A:$G,7,0)),1,0)
    Not sure about "Bloor-780" as this is occurring more than one.. how do you want to do it? will you consider any match?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  10. #10
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Thanks dilipandey, but yes with Bloor-780 it should look at each match and count if each one equals column F.

    Can this be done with match and index?

    Thanks again,

    Gabe

  11. #11
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Hello Gabe,

    Perhaps this?

    =SUMPRODUCT((Sheet2!A$16:A$36=A4)*((Sheet2!F$16:F$36)=ABS(Sheet2!G$16:G$36)))

    COpy down.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  12. #12
    Registered User
    Join Date
    10-21-2011
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    Haseeb: That worked perfectly!

    Thank you, I tried to do this a million times and it wasn't working for me. Although I did use ABS I think I tried -1*(Sheet2!G$16:G$36) which maybe was why it was broken.

    Thanks for all your help everyone for working with me on this.

    Cheers,

    Gabe

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

    Re: Count the number of items in a column that are equal to another column's #'s in same r

    @ gabe17

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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