简体   繁体   中英

Excel IF function across multiple rows and columns at the same time

I manage a student housing apartment building and have my rent roll within a excel document. In my property, residents are able to lease at multiple rent levels (whole unit, room within unit, or bed within the room). I am looking to be able count the number of "Vacant" rooms if both of the beds within the room are labeled "Vacant".

Column C has the unit number

Column D has the room number

Column E has the bed number

Column F has the resident's name

Unit 923(C1) room1(D1) Top(E1) John Doe(F1) Bottom(E2) Vacant(F2) room2(D3) Top(E3) Vacant(F3) Bottom(E4) Vacant(F4)

In this case, unit 923 is a two bedroom unit with four beds (two in each room). Room 1 is partially occupied by John Doe and is therefore not available at the room level. Room 2 has both of the beds "Vacant", so it is available to be rented out at the room level.

Thanks in advance!

You can nest logic with AND and OR to figure it out:

IF x AND y => true if both x and y are true

IF x OR y => true if either x or y are true

IF x AND (y OR z) => true if x is true and either y OR z is true

See here for some examples. Here is a more formal explanation

I added an additional column G to contain the results of the IF function. My final formula is:

=IF(AND(AND(F3="VACANT"),AND(F4="VACANT",AND(D4=""))),1,0)

I just add the new column's values for the number of available bedrooms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM