简体   繁体   English

如果其他单元格与列匹配,则Excel计算行中的某些单元格范围

[英]Excel counting certain cell range in row if other cell matches column

So I inherited an Excel file that is used to schedule and track PTO and OT time for about 100 employees. 因此,我继承了一个Excel文件,该文件用于计划和跟踪约100名员工的PTO和OT时间。 They have a column for every day of the year and have the year split over two sheets. 他们在一年中的每一天都有一列,并将一年分为两页。

I am trying to create a totaling sheet that shows a grouping for each employee and counts up each of the types of time codes that are used in the tracking sheets. 我正在尝试创建一个汇总表,该表显示每个员工的分组并计算跟踪表中使用的每种时间代码类型。 Each time type has a code that is used for condidtional formating NM1, NM2,... 每个时间类型都有一个代码,用于习惯性格式化NM1,NM2,...

I am trying to create a formula that will check the employee's name against the name column on the tracking sheet and then count just part of the row for cells that contain NM1, etc 我正在尝试创建一个公式,该公式将对照跟踪表上的名称列检查员工的姓名,然后仅对包含NM1等的单元格的行进行计数

Here is one of the cells as it is now: 这是现在的单元格之一:

=COUNTIF('2015MarNov'!$E$88:$AH$88,"*"&"NM1"&"*")

the employee name is in column D and this is counting NM1 for just January (columns E through AH). 雇员名称在D列中,仅在一月份(从E到AH的列)中就计算NM1。

Try this: 尝试这个:

=COUNTIF(OFFSET($E$1:$AH$1,MATCH(<target employee cell>,$D:$D,0)-1,0),"*NM1*")

In this example I assumed that row 1 contains the header and that row 2 starts with the employees. 在此示例中,我假设第1行包含标题,而第2行以雇员开头。 If that is not the case try something like this: 如果不是这种情况,请尝试以下操作:

=COUNTIF(OFFSET($E$5:$AH$5,MATCH(<target employee cell>,$D$6:$D$106,0),0),"*NM1*")

Edit, explanation: 编辑,说明:

Match(<target employee cell>,<range of employees>,0)

This function returns the relative row in which the target employee is found, ie if the employee is in D7 and the range is D6:D106 then the returned value is 1, since this the relative offset from the starting range (starting at 0) 此函数返回在其中找到目标雇员的相对行,即,如果该雇员在D7中且范围为D6:D106,则返回值为1,因为这是相对于起始范围的相对偏移(从0开始)

OFFSET(<range>,<rows>,<columns>)

This function shifts any given range by the number of rows and columns as specified. 此函数按指定的行和列数移动任何给定范围。 In the previous function the range is offset by 1 row (shifted 1 row down). 在上一个函数中,范围偏移了1行(向下移动了1行)。

COUNTIF(<range>,<criteria>)

The <range> is determined by the shifted range from the OFFSET function. <range>由偏移功能的偏移范围确定。

Use this: 用这个:

=COUNTIF(INDEX('2015MarNov'$E:$E,MATCH("NAME",'2015MarNov'$D:$D,0)):INDEX('2015MarNov'$AH:$AH,MATCH("NAME",'2015MarNov'$D:$D,0)),"*"&"NM1"&"*")

Change the "NAME" to the cell on the summary sheet the has the Employee name. 将“名称”更改为具有员工姓名的摘要表上的单元格。 You could also change the "NM1" to a cell reference. 您也可以将“ NM1”更改为单元格引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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