Excel counting certain cell range in row if other cell matches column - excel

So I inherited an Excel file that is used to schedule and track PTO and OT time for about 100 employees. 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,...
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
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).

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.

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. 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, i.e. 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)
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).
COUNTIF(<range>,<criteria>)
The <range> is determined by the shifted range from the OFFSET function.

Related

How to check if any day of given week number falls between range of date intervals

I have a sheet (1) where header cells of columns hold week numbers and dates of mondays per every week.
Then i have another sheet (2) of reservations. I would need to create reservation view to sheet 1 where each cell of each resource row checks from sheet 2 if any day in current week hits any reservation from sheet 2 and return a number for that cell (for formatting purposes, number 1 in example below). There are multiple rows in sheet 2 for each unique resource, so i could not use VLOOKUP, since it returns only first occurrence.
Those numbers 1,2,3,4... in sheet 1 are ISO week numbers 1-53.
Sheet 1:
Sheet 2:
I've tried to approach this with IF/AND/VLOOKUP, but with no success...
=IF(AND(D$7>=VLOOKUP(B9;gantt_data!$A$3:$E$52;4;FALSE);D$7<=VLOOKUP(B9;gantt_data!$A$3:$E$52;5;FALSE);;);1;)
Thank you for help already!
You can try SUMPRODUCT function:
=IFERROR(1/SUMPRODUCT(($B4=$A$16:$A$24)*((DATEVALUE(C$2 & C$1)+7)>=$C$16:$C$24)*(DATEVALUE(C$2 & C$1)<$D$16:$D$24));"")
I believe a simple COUNIFS will do the job. Please try this formula. Paste it into your cell B9 of your table on Sheet1 and copy it from there to the right and down as required.
=COUNTIFS(Table1[Task Name],$A10,Table1[Reservation start],"<=" & B$7,Table1[Reservation end],">" & B$7+7)
Note that I presumed your Sheet2 to hold Table1. Please replace the range with another name if a range Table1 doesn't comprise of the DataBodyRange of your table on Sheet2. To avoid seeing all the zeroes please format the cells with the formula as Custom 0;;

Summing values into new sheet for unique dates and unique names

So here is my scenario, I already have a sub that extracts unique names and unique dates from Sheet 1 into Sheet 2 creating the layout of unique names as rows and dates as headers. In Sheet 1 is the master data. For each day of the month, there are different work shifts for the same person. For example...
D Gray worked 3 different shifts on 6/26 so i need the values in Hours summed and then populated into Sheet 2 under the respective 6/26 date and so on and so forth for the other crew members. The template so far is..
Result of New Code
I can't see the image, but I understand your concept so hopefully you can apply the below to your case and use this as your answer.
Say the data in Sheet1 is columned as Date, Name, & Hours worked for A,B, & C respectively (for only 100 rows), your SUMIFS function in sheet2 should be as follows:
=SUMIFS(Sheet1!$C$1:$C$100,Sheet1!$A$1:$A$100,B$2,Sheet1!$B$1:$B$100,$A2)
This as you drag it down will hold the first column in sheet2, the names, and the first row in sheet2 the dates, summing up all the hours worked for all the days of the month.
If you use table formatting you can simply this further and the formula will resize with the table since it would use named ranges. I can help you with that as well if you'd like.
To have VBA add this formula to your spreadsheet use the following:
Dim RangeFormula As Range
Set RangeFormula = Sheet("Sheet2").Range( [input cell range here])
RangeFormula.Formula ="=SUMIFS(Sheet1!$C$1:$C$100,Sheet1!$A$1:$A$100,B$2,Sheet1!$B$1:$B$100,$A2)
You can change the name from RangeFormula to whatever suits better, you can put the sheet name where Sheet2 is but make sure you put the cell range in the range part with " surrounding it. To reference this as a table you'll need to use the ListObjects("Table Name")

VBA to find the last value in a row greater than 0 then return the header of that column as the value

I have a spreadsheet which has over 1000 rows of data. Column A consists of names and Row 1 has dates going across the top of over 500 columns.
I have another sheet which is a copy of column A and I want to put the date of the last entry of data that is greater than 0 into column B.
I want to do the following:
Find the last cell in each row that is greater than 0 (starting from the second row up to the 1500th row)
Then I want to have the date of that entry listed into column B of another sheet where I have the same names listed.
I'm completely stuck with this. I have tried to get VBA and formula's to work but I can only seem to get them to bring up the value of the last cell and not the date of the entry. An exmaple of one formula is below:
=LOOKUP(2,1/('Sheet1'!B2:ARJ2<>""),'Sheet1'!B2:ARJ2)
Hopefully, I would like a VBA solution, but I will take any solution right now!
Thanks,

Excel - look for value in column then count number of occurrences in corresponding row

I have two sheets that both share the same unique identifier (listed in a column). Sheet 1 contains the raw data and on sheet 2 I am extracting key figures and making calculations.
In sheet 2 I would like to add a count of the number of times a word, say "Apple", appears in sheet 1 in the row that corresponds to the same ID. So it's a formula looking up the ID in sheet 1 and then counting the number of times "Apple" appears in that row.
I couldn't find a solution to this anywhere, so I would be grateful for any help!
You can use this formula:
=COUNTIF(OFFSET(Sheet1!$1:$1, MATCH(A1,Sheet1!A:A,0)-1, 0), "*Apple*")
This supposes your ID column in sheet2 is column A, it will count the occurrences of Apple where the row matches the id in sheet1 cell A1. You can type it at any cell in first row and copy down in the column.
Also, if you want to match whole cell content for "Apple", you can remove the wildcards from "*Apple*".

Link two cells of a column in different sheets if a value in a cell of other column matches in other sheet

I have a workbook with 7 sheets containing part number of a product in column and its cost in adjacent column. And the 7th sheet contains total number of parts in all the sheets. I want to change cost of some products but then I have to do the same in all sheets. Is there a way by which it automatically finds and changes cost in individual sheets when i change it in the sheet containing total?
Use VLOOKUP on the first 6 sheets to match the price to each part number.
So, in each "cost" column on the first 6 sheets, enter this formula (assuming Cost on Sheet7 is still in column C):
=IFERROR(IF($A1="","",VLOOKUP($A1,Sheet7!$A:$C,3,FALSE)),"")
If you have header row(s) then just replace the two instances of $A1 in the formula with whatever the first row of data is (e.g. $A2), paste the formula into that row in column C on Sheet1, then drag-copy the formula down as far as you want. Repeat for sheets 2-6.

Resources