Excel increment cellsand skip weekends or holidays - excel

I had a google sheet that I am trying to translate to an excel file. The original formula is this:
=Arrayformula(if(J2:J<>"", regexreplace(J2:J, "[^A-Z]",), if( (weekday(B2:B) = 1)+(weekday(B2:B) = 7), ,countifs (weekday(B2:B), ">1", weekday(B2:B), "<7", J2:J, "", row(B2:B), "<="&row(B2:B)))))
I am looking to convert this to something in excel. Basically the idea behind this formula was that it would count down a column (A) looking at the next column (B) to see what the date was. If it was a weekend, it would skip the increment. If it was a work day, it would increment. This allowed me to automatically count down 20 work days for a sprint. Then it would look at a 2nd column (J) for any Notes in that column. If anything was in the column, it would skip that increment and put a letter in that row (column A). For example, if I put "Holiday" in column J, it would be an "H" in that row in column A. That way I could still count down to plan out 20 work days easily.
It worked fine in Google Sheets, but the translation to Excel was not as easy as I would have hoped.

You can use WEEKDAY.
For example, based on your description you could try:
=IF(OR(WEEKDAY(G2)=1, WEEKDAY(G2)=7), "",
IF(ISBLANK(H2)=FALSE, H2,
MAX(F$1:F1)+1))
EDIT as suggested by #Marti:
A much cleaner way is to use a second argument in the WEEKDAY function, and then cut down on the number of characters in the second IF.
=IF(WEEKDAY(G2, 3)>=5, "",
IF(ISBLANK(H2), MAX(F$1:F1)+1, H2))

Related

Finding the last occupied cell using a formulae

This formulae "works", but it seems a bit long winded. Can anyone suggest an "easier" formulae. It returns the value in the 5th Column to a date in the 1st column which is called from a separate (and discrete) worksheet. If there is no data in the 5th column (because we haven't reached or passed that date), then the latest available data is called ($A$20, is the "calling date, on a current worksheet):-
IF(VLOOKUP($A$20,'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5)="",VLOOKUP(HLOOKUP(A20,'[FTSE100.xlsx]Meteor Step
Down Plans'!$A$18:$A$2628,MATCH(TRUE,INDEX(ISBLANK('[FTSE100.xlsx]Meteor
Step Down Plans'!$E$18:$E$2828),0,0),0)-1),'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5),VLOOKUP($A$20,'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5))
The formula is in a different workbook to the data. The formula is used to determine the last value in an array, the first column of which is a date range (01/01/2000 to 31/12/2027....say) The required data is in column 5. Entries may be up to date (i.e. the last entry was made today, therefore it will pickup todays value. The last entry may have been several days (weeks) ago, therefore it will pick up the last value in the designated column (column 5). I don't see why it can't go into a named range, as the array size is fixed. Does that help?
Thanks Ron, nearly there. That works beautifully for "missing" dates in the array. i.e. when Saturday and Sunday dates are missing, it finds the value (in column 5) of the previous Friday. However (and there is usually a "however"), if $A$20 is a date in advance of the date of the last data in the array i.e. column 5 is blank at that date, your formulae returns 0 (zero), instead of the data as at the last date that data has been entered. i.e. enter 02/04/2018 and your formulae returns 0, not the data at the last date available 28/02/2018. Is that a little more clear?? (Thank you anyway, for spending the time - I'm still trying to work out how your formulae works as it does. Is the "/" significant (other than being a "divide by" symbol, if so it's something I've never come across before? Regards...........Mike. P.S. The dates in the array (Column 1) are all in from 2016 to 2027 (excluding weekend and bank holidays), and are arranged in ascending order i.e. from 01/01/2016 to 31/12/2027
Ron - Sorry mate, buy I can't see a "second" formulae???
If I understand what you want to do correctly, (and that is hard to do since you give NO examples of your data, actual output or desired output), try:
=LOOKUP(2,1/((myDate>=A:A)*(LEN(A:A)>0)),E:E)
If it is the case that you have dates in column A and no entries in Column E, then you might have to do something like:
=LOOKUP(2,1/((myDate>=A:A)*(LEN(A:A)>0)*(LEN(E:E)>0)),E:E)
Of course, you will have to modify the cell references and named range to refer to the proper workbooks and cell.
Possibly something like:
=LOOKUP(2,1/(($A$20>='[FTSE100.xlsx]Meteor Step Down Plans'!$A$18:$E$2828)*(LEN('[FTSE100.xlsx]Meteor Step Down Plans'!$A$18:$E$2828)>0)),'[FTSE100.xlsx]Meteor Step Down Plans'!$E$18:$E$2828)
This should return the item from Column E that is either at or above the same row as myDate in Column A. If myDate does not exist in column A, it will match the nearest earlier date in Column A and return from that row in Column E.
In the second version of the formula, it also checks that there is an entry in Column E matching the column A date, and, if not, it will look above.

forumla automatcally filled when another cell value is added - Excel

I have: =NETWORKDAYS(N25, AJ25-1) in Column O to calculate the number of busines days since an item has gone out of the building. right now I am manually duplicating it each time a new item goes out.
But is there a way to put a formula that when Column N is filled out, it will automatically added in the formula above in Column O respective to the row?
On that note, it seems my formula is a bit wonky. It works perfectly when it gets to the day AFTER it was sent out (day 1), but if it's sent out today, it will come back with the value -1 or -2 instead of "0" indicating that today's date (AJ25) is the same as the value I entered in on Column N.
I can understand why it does that but not sure how to calculate it so it doens't count today's date but starts the day after.
It seems #Jeeped's formula met the requirement:
=if(isblank($N25), "", NETWORKDAYS(N25, MAX(N25, AJ25))-1)

EXCEL - SUM column if date matches TODAY()

I've tried using SUMIF to obtain my results but it doesn't work properly.
I have a row of dates (XX/XX/XXXX format) and I would like to check this row for the current date.
If the row contains the current date, then I would like to sum the total of that column and row 5-20.
For example - today is 10/13/2016. I would like to search for TODAY() in a certain row (Row 1 for example), and if TODAY() is found, then total this column from row 1 down to row 3.
--A-- --B--
10/13/2016 10/14/16
1 50 10
2 10 4
3 5 6
The result should be 65 only IF the date matches TODAY().
I've also checked on giving the column letter based on the date but with no luck.
Any tips are appeciated! Thank you.
I think you can achieve this with a simple IF and a SUM
i.e. in your example above if you want the result to appear on the bottom row you can just use:
=if(B2=today(), sum(B3:B5), "")
This will display the sum at the bottom of the column for columns where the date = today and a blank in the other columns
You need to use the OFFSET function. You can find the documentation here: https://support.office.com/en-us/article/OFFSET-function-C8DE19AE-DD79-4B9B-A14E-B4D906D11B66
In your particular example the following formula will work:
=SUM(OFFSET(D2, 1, MATCH(B2, $D$2:$F$2, FALSE) - 1, 20))
You can see the formula working below. Assuming you know what the SUM formula is doing, I will explain what the OFFSET formula is doing:
First Parameter: Says start at cell D2
Second Parameter: This is how many row up/down do you want to do. In your case you need start at row below the date so '1' it is.
Third Parameter: This is how many columns to the right do you want to
go. Well the number of columns you want to go is based upon where
your date is. So this uses the match formula to figure out how far
to the right to go.
Fourth Parameter: This is how many row do you want to include. I just picked 20 to include the 20 rows below the selected cell.
You obviously need to modify the parameters a little bit to fit your exact data shape.
So I'll give it a shot:
{=SUM(HLOOKUP(TODAY(),Table_With_Dates_and_Three_Rows_Cell_Reference,{2,3,4}))}
NB: Don't type {} but put the formula inside it and then hit Ctrl+Shift+Enter to create what is called an array formula (it does array calculations element by element then submits the aggregating function value---in this case that is sum).

Search column for text value, if value exists check other column for number of days from the date today?

I have an Excel spreadsheet like so:
A B
27/03/2015 Riddor
28/03/2015 Text
09/03/2015 Bees
What I am trying to do is search my column B for the word Riddor using this function:
=IF(ISERROR(MATCH("Riddor",Statistics!B:B,0)),"No Match",TODAY()-MIN(Statistics!B:B))
Within this function if the value Riddor is not found I want to show 'no match' else if the value is found I want to identify the most recent occurrence of the value Riddor in my column where its date in column A is the most recent from today. I then want to count the number of days.
So for instance my value Riddor in column B has a date of 27/03/2015. The number of days from this date to today is 5, however if I add another Riddor with a more recent date like so:
27/03/2015
31/03/2015
then I want my day count to show 1 day instead of the previous 5 days.
Can someone please show me where I am going wrong and what to do to get this working?
You will need to use a formula as defined below
Note that the flower brackets indicate that you are using this as a range formula which means you will need to hit Shift+Control+Enter and when you click on that Cell it will create the flower brackets in the end.
The below formula will retrieve the MAX Date the next part is quite simple you need to subtract from today to arrive at the difference in days. Preferably do it in another cell. I have accounted for different sheets in a modified formula at the bottom of this post. But you can test the below on the same sheet and then copy over the cell to another sheet to have it dynamically correct to account for sheet if you like. Either ways the below is tested with all events and is working
{=IF(COUNTIF(B:B,"Riddor")=0,"No Match",IF(COUNTIF(B:B,"Riddor")=1,INDIRECT("A"&MATCH("Riddor",B:B,0)),MAX(IF(B:B="Riddor",A:A))))}
Explanation
Part I - =IF(COUNTIF(B:B,"Riddor")=0,"No Match" Counts if there are any occurance of the word Riddor in that Range
Part II - IF(COUNTIF(B:B,"Riddor")=1,INDIRECT("A"&MATCH("Riddor",B:B,0)) this part accounts if there is only once occurance of the word Riddor then it uses the Match function to retrieve the date from the A Column. It would be easier with VLOOKUP but I'm assuming you dont want to change the Column Order for A & B
Part III - MAX(IF(B:B="Riddor",A:A)))) This where the Range formula is actually required. It checks in the Range B:B and Retrieves all the Dates where the B Column Matches "Riddor" and then Finds the Max date in that subset Range which would be the date closest to today's date.
Tested and Working perfectly in sample provided by your even with Multiple instances of Riddor.
Formula Accounting for the difference in Sheets not tested yet.
{=IF(COUNTIF(Statistics!B:B,"Riddor")=0,"No Match",IF(COUNTIF(Statistics!B:B,"Riddor")=1,INDIRECT("Statistics!A"&MATCH("Riddor",Statistics!B:B,0)),MAX(IF(Statistics!B:B="Riddor",Statistics!A:A))))}

Excel (numbers) formula

this should be simple enough, but numbers (on OSX) keeps throwing an error about the ranges being different sizes.
I have a list of numbers, each with an associated date, and I want a sum of all numbers within a particular month (to give, on a separate sheet, a monthly total).
Here is what I've tried:
SUMIFS(
Sheet1::Table 1::D2:D84,
MONTH(Sheet1::Table 1::A2:A84), "=04",
YEAR(Sheet1::Table 1::A2:A84), "=2014"
)
Sorry if this is a stupid question, but I've tried fiddling with it and it just won't accept it.
Thanks in advance.
You cannot put a function inside the range:
=SUMIFS(C1:C25;Month(A1:A25);"=3")
than you need to add two (hidden?) columns with Month & year function.
After you build SUMIFS based on the new columns
=SUMIFS(C1:C25;D1:D25;"=4";E1:E25;"=2014")
sum all value from C1 to C25 if column of month (D) is equal to 4 and column of year (E) is equal to 2014.
I would suggest considering using a SUMIFS function with an upper\lower limit, and then either referencing a cell with the dates, or using their numerical value in the formula (the former is my preference, to reduce hard coded values = easily updated\reused). So something like:
=SUMIFS(D2:D84, A2:A84, ">="&E1, A2:A84, "<="&E2)
In this example:
column 'D' has the values you want to sum
column 'A' has the date values
columns 'B' and 'C' are treated as irrelevant (for the sake of this formula)
column 'E' has 2 values, in row 1, the lower limit (for this specific question, the first of April) and in row 2 the upper limit (for this specific question, the final day of April)
Then have your lower limit for dates (the first day from when you would like column 'D' to be counted) in cell E1, and your date upper limit in E2.
Easily updated for future months, so might save you some work down the line.
The next easier option would be to update it to be formatted as a table, because your formula would be slightly more legible, add in some named ranges (in this case, E1 = 'lowerlimit' and E2 = 'upperlimit) to once again make it easier to read the formula, in which case you'd end up with something like:
=SUMIFS(table[FigureToBeAccrued], table[dates], ">="&lowerLimit, table[dates], "<="&upperlimit)
Might've overcooked this answer, it's my first, so wanted to make sure I didn't skimp. Let me know if you've got any follow up questions.

Resources