I'm looking for a formula or a VBA code for the following problem.
I need to get the total operational hours in a day (J). This is de difference from the start-up time (I) and the shutdown time (K) over the whole day.
Most of the entries are 2 a day, but as you can see in the picture this one has 4. Previously I had the formula in J : =IF(K49="";0;IF(EXACT(A49;A48);(K49-I48);(K49-I49))) But with 4 entries this does not work anymore (the A49 and A28 are just numbers if they are the same it means that it is the same day)
So where I'm basically looking for is that it will take the shut downtime and looks for the first value in I and that it is calculating the difference in J.
Referring to another cell can be done, using OffSet(Row, Col). In case you need the cell just above, you use OffSet(-1,0).
I would just use some nested IFs to check first the row above, then the one above that, then the one more above.
Something like this (sorry, I cannot embed images):
https://i.stack.imgur.com/XLHVO.png
Related
I am trying to create an editable calendar of availabilities, wherein people can input that they are available either during the day, at night, all day, or not at all.
I would like the calendar to automatically highlight days when there is an overlap of availability - say, when everyone is free at night, or some are free all the time and one only during the day.
I can do the former by using the formula =AND(($C2:$G2)="night") - when all five people input "night", it highlights as fully available. However, my problem is with the "All the time" variable.
How would I create a conditional format that highlights cell A2 (for example) when all of the cells in range C2:G2 are filled with either "day" or "both"? So far I've gotten to =OR($C2:$G2="day",$C2:$G2="both"), but this has the problem of highlighting A2 if even just one cell in the range has the desired value. I assume I have to include an AND command here, but how exactly?
Thank you for any help :)
Screencap of calendar: Columns A and B are filled with days/dates. C1:G1 are labelled Person 1 - Person 5. Each person has filled an availability for each date, either "night", "day", "both", or "NA".
Another solution would to be using a couple COUNTIF() functions and comparing to the total, in your case 5 since you have 5 columns.
Sum the results of the two COUNTIF() functions, if they equal 5, your data is highlighted:
=COUNTIF($C2:$G2,"day") + COUNTIF($C2:$G2,"both") = 5
Essentially, if the left side of your equation is equal to the right side then it will return True.
This can be a little more portable. Only need 3 or more of the 5 cells? You could simply change to >= 3 instead of being = 5.
In the event no one is able to come up with a more elegant solution, here's one that at least would work for you. Not too bad if you only need to compare the 5 columns, could be a bit more painstaking if you have more.
=AND(OR($C2="day",$C2="both"),OR($D2="day",$D2="both"),OR($E2="day",$E2="both"),OR($F2="day",$F2="both"),OR($G2="day",$G2="both"))
The And() function, as you are likely already aware, requires that each and every value within it returns a True value to have it output a value of True.
I am trying to find a difference between 2 dates using networkdays and additionally if both dates are equal, have to make the value as 0. But unable to get the result.
You can try
if(DATEVALUE(A1)=DATEVALUE(A2),0,NETWORKDAYS(A1+1,B1)
#Ron Rosenfeld has pointed out that my testing led to wrong conclusions. Therefore I increased the volume of my tests. They continue to show that ...
Comparing the two dates and adding a day gives erratic results, and that
The naked NETWORKDAYS function as designed by Microsoft gives the most useful result.
In the table below the original function is in column C, your function (modified to work by #Ron Rosenfeld) in column D and two variations thereof in columns E and F. The lower part of the table shows results where both days are the same while the dates are 2 days apart in the upper part.
The tables show that the original formula counts both the start and the end days as well as all days between them, subtracting weekend days, except when start and end days are the same. In other words, the original function already treats the case of A1=B1 differently.
However, if an adjustment is to be made it should preferably be made to the result of the formula, not be modifying the date before they are processed. This is demonstrated in column F.
The formula in column E takes up your attempt to modify one of the dates (the end date could be modified too) and makes this conditional. The difference as compared to your formula is that you apply in fact two separate calculations, one where the result is always 0 (when dates are equal) and the other where the start date is advanced by one day unconditionally. If it suits your purposes that method can still be applied but the formula in column E shows how the date modification can be made conditional.
The need to apply conditions arises from the essential shortcoming of your formula in that it applies the wrong condition. Different treatment for when dates are equal is already incorporated in the basic function. Any further modification must take the involved weekdays into account, not (necessarily) only the interval between the dates.
Why do you put your formula arguments in quotes? That just changes them into strings, which is why your formula doesn't work.
I assume from your formula that you just don't want to count the first day. In which case it will work as you have it, if you merely remove the double quote marks.
I have a task in in excel and I can`t think of the solution right now.
So I have a spreadsheet with running competition results: The table looks like this
So I need to detect which is the fastest runner that has ran all 3 laps (the winner) and detect the number(Nr) of the winner.
The F column is for calculations if needed
So I detected who had ran all 3 laps with this formula:
=IF(COUNT(C2:E2)>2;SUM(C2:E2);"DNF")
Then I determined who is the winner by running a min formula:
=MIN(F2:F79)
Now I need to detect what number the winner has, So it will be in the A column and in the same row where the row where =MIN(F2:F79) result is.
This is an task so manually finding it won`t work this time.
It is probably a really simple solution but I can`t think of it right now so it would be really nice if somebody could help out.
You can achieve this utilizing Index - Match.
The formula you would place in cell H2 would be as follows:
=Index($A$2:$F$79,MATCH($G$2,$F$2:$F$79,0),1)
What this does is it looks at the whole table and takes the Winner total time (cell G2) and matches it with the corresponding value in Column F, and then returns the first column (Column A).
Essentially I am looking at a schedule and trying to figure out how many times a person worked a block - meaning their name will appear in columns side by side.
Each column represents a day of the week. So if John worked Mon - Tues that counts as a block and his name would appear in 2 columns. He then may work Thurs - Sat and that counts as a block. I need to figure out how often this occurs over the course of a month.
Manual counting using conditional formatting is one option - but I'd like to avoid it if possible.
Thanks for your help all, It is much appreciated!
For a solution in Excel, If John's schedule for the month is in row 2 (range B2:AF2), then try this for the number of blocks he worked (enter as an array formula with ctrl+shift+enter):
=SUM(--(IFERROR((B2:AF2="John")+(C2:AF2<>"John"),(AF2="John")+1)=2))
This assumes that if John worked a single day without working the day before or day after, it would still count as a block. Also, Note that if your schedule may contain error values (e.g., from being filled in with a formula), you'll need to wrap the schedule with IFERROR:
=SUM(--(IFERROR((IFERROR(B2:AF2,"")="John")+(IFERROR(C2:AF2,"")<>"John"),(AF2="John")+1)=2))
I want to count number of cells containing the value time. Eg: 05:29, 14:36, 22:05.
Here, these times are entered in indiviudal cells. And I want to count number of cells containing time. Like Time: 3. But not the time function or total time function
-Thanks
Assuming your data is arranged like this
you can use =COUNTIF(B1:L1,">0") to count the non empty cells, and you will get then this
If you want to check for late arrivals, use this formula = IF(Q2<>"",IF(Q2-Z2 >0,"L","N"),"") where I called Q2 the cell containing the arrival time and Z2 the cell with the expected arrival time. You will get a L for late arrivals, a N for an arrival on time.
Another solution along the same lines as L.Dutch is to use the IsNumber() function of excel. It requires two steps. First using that function and then summing the TRUE values. The one advantage of this method is that it makes it more explicit as to what it will add up.
Thought I'd provide this in case it is useful, but I would use L. Dutch's answer first.