Data validation for calculated cell - excel

I'd like to make it so that an error is returned if a calculated cell attempts to go below zero. I have made a vacation day excel sheet so that if a person schedules a vacation day, the total amount of vacation days remaining decrease. The thing is, if I schedule for more days than I have available, the calculated cell for the remaining days will go into the negative values since it is calculated and not user entered. I used data validation on the cell and if I try to manually enter a negative number it wont allow me. I just want the same thing to happen for a calculated cell.

Data Validation is not appropriate for this task, instead use:
=IF(your_formula<0,"ERROR",your_formula)

If Column A is Total Vacation Days allowed, Column B is the Total Vacation Days Used, and Column C is the formula =A1-B1, then apply custom data validation to B1. The formula would be =B1<=A1. That should work. It's not applying it to the answer cell, but the input cell creating the error.

Related

VLOOKUP to find weeknumber

I'm sure there is a more appropriate method for this, but I have layers of referencing so it has to be done this way. My spreadsheet is like an onion.
I need to be able to pull the week number based on a value defined in another sheet. So far the user enters the date when they start the sheet up. It is always the 1st of the month. This is then reference for a host of things elsewhere. This value is currently in =Front!$C$3. I have a visual calender set up as 53 rows, with 1 row per seven day period. I had written =VLOOKUP(O25, $S$2:$Z$54, 1, FALSE ) which had worked on a two column table for another task with different referencing. Currently I get #N/A as the return.
I'm assuming there is a way to have the cell check the red area for a value matching 1/1/23 (formatted as a custom format to just show the day number) and return the value in column 1 (the week number)
In my case O25:O36 is just 1/1/23:1/12/23. N25:N36 is the same just referencing the adjacent cell for O.
If there is a more straight forward way of having a cell return the weeknumber for the first day of each month, so I can have a cell on Front! return the week number based on the value in =Front!$C$3 that would be ideal also.
Thanks for the second time to #FoxfireAndBurnsAndBurns again, for pointing out a simple answer. ISOWEEKNUM with the dates of the first of the month has resolved.
=ISOWEEKNUM("1/1/23")

N-Count Days For Changing Dates For Ecommerce Shipment Sheet

I have to submit a daily MIS for orders which are Undelivered For less then 2 Days, Undelivered Between 3-5 Days and 5+ Days.
Currently i'm doing this manually by counting from the Purchase Date forward. So e.g. for an order of 11th March, i'll just count 2 days till 13th (If undelivered) and type 1 in front of the column and do a count manually of all orders outstanding in each column.
The problem arises as the column descends and the dates get further and further away from current day.
This is tiresome but i can't seem to find an algorithm that can do this automatically.
Can anyone help please.
Consider this screenshot:
Cell A1 has the date you want to compare to. Don't user the Today() function, since it is volatile and can slow down the workbook. Just manually put in the desired date.
The formula in cell E2 is
=IF(D2="undelivered",IF($A$1-C2<=2,"less than 2",IF($A$1-C2<=5,"3 - 5 days","5+ days")),"")
In words: if the status is "undelivered", calculate the difference between purchase date and A1. If it is less than 2, return that text, if it is less than 5, return that text, otherwise return the third text.
Copy that formula down.
In cells G3 to G5 you see each of the three texts and next to it is a formula. Starting in H3
=COUNTIF(E:E,G3)
copied down to H5.
Your layout may differ, so you will need to adjust the formulas accordingly.

How to make criteria in AVERAGEIFS update automatically?

I am trying to make my AVERAGEIFS criteria update automatically according to the day of the year (in this case only for 2014). My original AVERAGEIFS formula works perfect =AVERAGEIFS($B$2:$B$35041,$A$2:$A$35041,">=1/1/2014",$A$2:$A$35041,"<1/2/2014"), but I have to manually edit it for each day of the year.
I have tried modifying formulas I have seen in other posts here, but no luck so far. I want to average the values in column B (Amount) for each day in column A (Date). I have 96 time slots for each day of the year, hence the 96 entries in column A with the same date, e.g. 1/1/2014 and so on until 12/31/2014. How can I modify the formula so that it automatically adjusts the day when I drag it down?
Here is a screenshot of the data:
Screenshot of data
Any help is much appreciated!
EDIT: Updated formula below; I had misread the original question as to how your data was formatted. You can put this formula in B2 and copy down.
=AVERAGEIFS($B$2:$B$35041,$A$2:$A$35041,">="&$A2,$A$2:$A$35041,"<"&($A2+1))
Your original comparison operator hardcoded a date as a string. We can simply concatenate the value of a cell into that comparison string instead.
Granted, this will do the same calculation for each of the 96 entries for each of the days in your sheet. You could add a second sheet for the averages with just the distinct days of the year listed in A and an average calculation in B.
EDIT 2:
If your entries in column A have fractional date information (i.e. with hours, minutes, and seconds), converting the dates to integers will drop any fractional component:
=AVERAGEIFS($B$2:$B$35041,$A$2:$A$35041,">="&INT($A2),$A$2:$A$35041,"<"&INT($A2)+1)

Excel Formula to Calculate Checkin Time

I have a file from restaurant log of 1 month. I need to calculate the Checkin Time time from Time and Bill Number column.
My Format is:
Date |Time| TableNumber| Checkin time |Bill Number ..|...|...|
I can calculate it manually one at a time by copying the 1st data of Time column and copying in Checkin time where bill number is same.
I have attached a Screenshot of the data.
Example 1: Blue square
Here in the blue square we can see that first value of Time column is 0:02:37 and I have pasted it in Checkin time which has Bill Number 29 .
Example 2: Red square
First value of Time is 16:08:40 And I have pasted in Checkin time column which have bill number of 1 and so on..
I did it manually without any equation or formulas. But the problem is the data is of 1 month and I have about 6 to be calculated.
What I tried
From the formula given to me by #girlvsdata
I tried
=MINIFS(B:B,E:E,E3)
I did get the data for 1st two unique Bill numbers, but after dragging down the forumla further down, I get different Time for new bill number. + as the bill number repeats in further down rows many times, it gives me same time of 1st bill number for repeated bill numbers.
Here is the screenshot of after What I tried
Screenshot_after
I propose the following:
=IF(AND(E3=E1,C3=C1,A3=A1),D1,MIN(OFFSET(E3,0,-3,MATCH(0,(E3:E$18=E3)*(C3:C$18=C3)*(A3:A$18=A3),0)-1,1)))
It is a bit long and will likely take a while to calculate if you have lots of rows. The above formula is to be entered as an array formula, i.e. copy/type the formula then instead of pressing Enter, use Ctrl+Shift+Enter. If you do it right, excel will insert {} around it like in the screen shot below:
Change the ranges E3:E$18, C3:C$18 and A3:A$18 accordingly and notice that they are all one row below the end of the table (otherwise you get #N/A for the last bill).
If you have the latest version of Excel, you can use =MINIFS() to find the first Time for that particular Bill Number (the Checkin time).
In cell D3 enter this formula:
=MINIFS(B:B,E:E,E3)
Make sure that the cell has Time formatting for it to show correctly.

How To Ignore Blank Cells for a Formula

I'm tracking hours for my company and I need to see the updated hours daily. I have everything formatted how I want it, except I want two columns to show how many hours over and under each employees current hours are.
What I have right now is
=(D3-C3)+(F3-E3)+(H3-G3)+(J3-I3)+(L3-K3)+(N3-M3)+(P3-O3)
But it is including all the empty cells (for days that haven't been worked yet) as a zero.
I want a formula that can allow me to ignore those blank cells until they have content.
I can't just use a SUMIF >0 function because I need to count the number of hours employees have MISSED (i.e. scheduled 12 hrs, actually worked 0).
Here's an alternate approach to #Tom's, though it works on similar principles. This one, however, relies on your ability to add a couple of 'HELPER' rows, above your current data.
I'm assuming that row 1 will alternate between saying "PROJECTED", and "ACTUAL".
I'm assuming that row 2 will be dates for that week, in Date format. So A2 will be Jan 1 2015, B2 will be Feb 1 2015, C3 will be Feb 1 2015, or however often the time blocks go up. The key here is that the PROJECTED columns and the ACTUAL columns will each need the date in them.
The formula to check the variance between that row's PROJECTED amount and that row's ACTUAL amount, only for dates prior to today, is (for row 3 and copied down, and assuming the data goes to column Z):
=SUMIFS(A3:Z3,$A$1:$Z$1,"PROJECTED",$A$2:$Z$2,"<"&TODAY())-SUMIFS(A3:Z3,$A$1:$Z$1,"ACTUAL",$A$2:$Z$2,"<"&TODAY())
This checks to see the value of PROJECTED columns for that row, where the date is less than today, and subtracts the value of ACTUAL columns for that row, where the date is less than today.
If you are looking to compare with something other than TODAY(), you can set up a cell to be your 'comparison point'. Manual type the breakoff period you are concerned with into that cell, and replace "&TODAY()" with, say, "&AA1" [assuming your breakoff point is entered in cell AA1].
As it stands, either a very long series of IF's and OR's or an array formula:-
=SUM(IF(OR(D3="",C3=""),0,D3-C3),IF(OR(F3="",E3=""),0,F3-E3),IF(OR(H3="",G3=""),0,H3-G3),IF(OR(J3="",I3=""),0,J3-I3),IF(OR(L3="",K3=""),0,L3-K3),IF(OR(N3="",M3=""),0,N3-M3),IF(OR(P3="",O3=""),0,P3-O3))
=SUM(D3:P3*ISEVEN(COLUMN(D3:P3))*(C3:O3<>""))-SUM(C3:O3*ISODD(COLUMN((C3:O3))*(D3:P3<>"")))
The second one must be entered with CtrlShiftEnter
Note that it could easily be broken by insertion/deletion of columns.

Resources