date based on yes or no value in another column - excel-formula

Column G will either be blank or have a yes or no in it. Column L has a date value in it. IF column G has a yes in it I want column R to subtract 9 months from the date in column L. If column G is blank or no I want Column R to remain blank.

Enter this formula in column R (the below formula will work for row 2):
=IF(G2="Yes",DATE(YEAR(L2),MONTH(L2)-9,DAY(L2)),"")
Note that the adjustment of 9 months might look a bit odd. If your date is, say, 30 November 2018, the formula is supposed to return 30 Feb 2018. However, since no date exists, it will instead return 02 March 2018 (which is Excel's way of saying as two days after 28 February 2018).

Related

Excel formula to look up date that corresponds with 2nd 'non zero' value in column

In an excel model with two columns, column A = date by month, column B = cash projections (only two values in column B). Hoping to create a formula to search column b for the second value and return the corresponding month from column A.
In example below, looking for formula to return 'May 20' as answer
Column A
Column B
Jan 20
240,000
Feb 20
Mar 20
Apr 20
May 20
345,000
Jun 20
Tried using a min/max function, however, the second value is not consistently higher or lower than the first value. Assuming it can be done with some type of INDEX or LOOKUP function, however, I am unsure of how to select the second non-zero value

excel nearest due date

I have a row with dates and below it I have an empty row where I can type a "C" on any number of cells wanted or needed to get the dates above it, but I only get the first C, so what I am trying to do is actually ignore every "C" that I have wrote that correspond to past dates from today and only give me the closer one or next one from today.
For example: lets say that today is July 1 2018, so I have row 1 with a series of dates like A1=June 30 2018, B1= July 1 2018, C1=July 2 2018, D1=July 3 2018, etc and in row2 I have typed C on A2, C2 and E2 so with HLOOKUP it returnsJune 30 2018`, but I dont want that since that date is now in the past, I want to get the next and more close date after the present day so it should be C2 that is July 2 2018, and so on since the today formula will update as the days pass.
This is to get the next checking date on a project cronogram so all the dates are defined but the result as for each task should be automatically updating to stay relevant for the scehdule, so past dates just dont make any sence to be the results showed on the gantt table diagram, and yes I know it is easy as just to be deleating the "C" that correspond to past dates, but then what is the point of excel then?
I'll go out on a limb here.... you want to find the first C in row 2 after todays date which is in row 1.
MATCH will tell you which column todays date is in: MATCH(TODAY(),$1:$1,0) returns 3 as 2nd July is in C1.
INDEX will return a reference to the cell below todays date when used in conjunction with MATCH: INDEX($2:$2,,MATCH(TODAY(),$1:$1,0))
COUNTA will tell you the last column that's populated with dates in row 1: COUNTA($1:$1) returns 9 in my case as I've put dates from A1:I1.
Use INDEX again to return a reference to the last cell in row 2. INDEX($2:$2,,COUNTA($1:$1))
Stick both INDEX's together to get a range reference from todays date to the end of you data: INDEX($2:$2,,MATCH(TODAY(),$1:$1,0)):INDEX($2:$2,,COUNTA($1:$1)) - this returns an error as it's returning the reference to multiple cells.
Now find the first C in the referenced range: MATCH("C",INDEX($2:$2,,MATCH(TODAY(),$1:$1,0)):INDEX($2:$2,,COUNTA($1:$1)),0) returns 1 as I've got a C in 2nd July.
Add the column that todays date is on to the column that was returned (and minus 1 for the hell of it). SUM(-1,MATCH(TODAY(),$1:$1,0),MATCH("C",INDEX($2:$2,,MATCH(TODAY(),$1:$1,0)):INDEX($2:$2,,COUNTA($1:$1)),0)) returns the column number of the first C on or after todays date.
Use that number to return a reference to the date in row 1: =INDEX($1:$1,,SUM(-1,MATCH(TODAY(),$1:$1,0),MATCH("C",INDEX($2:$2,,MATCH(TODAY(),$1:$1,0)):INDEX($2:$2,,COUNTA($1:$1)),0))).
So your final formula is:
=INDEX($1:$1,,SUM(-1,MATCH(TODAY(),$1:$1,0),MATCH("C",INDEX($2:$2,,MATCH(TODAY(),$1:$1,0)):INDEX($2:$2,,COUNTA($1:$1)),0)))
Bit long, and I'm sure it can be done in a much shorter formula.
Edit: I also agree with Rawrplus - you could've explained it a bit better.

If condition to count column values based on index number

I have 14 column with 1st column (say A) containing the month value (1 for Jan, 2 for Feb and so on). Colum B contain a number representing 2017 year value. For the next 12 columns starting column C onwards, there are values for each month of 2018 starting from Jan 2018 till Dec 2018. In Col 15, i want to sum value of 2017 (Column B) with corresponding months in 2018 based on the month value in Column A. For example, if the month value is 3, then the result should give me the sum of values in column B(2017) + column C(Jan2018) + column D(Feb 2018) + column B (Mar 2018). Since month value 3 represents March 2018.
I tried to use the function Choose but seems too length. Is there a smaller and easy function?
=SUM(B2:INDEX(C2:N2,1,A2))
INDEX(C2:N2,1,A2) here gives the reference within C2:N2 at row 1 and column from cell A2. The range from SUM then becomes B2 to the reference obtained from INDEX.

Get value of cell above last cell in column

I am looking for a formula that will get the value of the cell above the last cell in a column in Excel. I have the following formula that will get the value of the last cell in the column:
=LOOKUP(2, 1/('Historical Data'!A:A<>""),'Historical Data'!A:A)
But I am looking for the value of the cell that is right above it.
For example, if I have a table that looks like:
A B C
2013 09 $40
2014 10 $78
2015 02 $60
I'm looking for column A to return "2014", not "2015" as it does now.
To return the second to last value I would use INDEX.
=INDEX(A:A, COUNTA(A:A)-1, 1)
COUNTA to get the length of your array and -1 to step to the second to last value.
Setup a meta row.
For example, in column "D", adjacent to each cell issue the following formula.
=ROW()
Like so,
A B C D
2013 09 $40 1
2014 10 $78 2
2015 02 $60 3
At the end of the last row, issue a MAX command in the row column. In the aboe example, it will be D4.
=MAX(D1:D3)
D4 will have a value of 3
This tells that your range has 3 rows. You may then get your cell value by
=INDIRECT("A" & D4-1)
Which will give you the value of A2.
You may hide row D after everything checks out.

add values for a range between reference date minus 6 days in excel

i would like to add the corresponding values of dates with reference to a particular date and -6 days in excel.
For example: reference date is 10th feb 15. I would like to add values under flight time column for dates ranging between 10th feb 15 and previous 6 days.
similarly add values for a reference date and previous 30 days values and 1 year values.
What i wanted was, sum all the flight timings of a particular date in column A. I used the sumifs formula to achieve this.
The formula is =SUMIFS($I$8:$I$1122,$A$8:$A$1122,"<="&C8,$A$8:$A$1122,">="&C8-6)
What it does: Here the reference cell is C8 which is 6th Feb 14
step 1- date range for the calculation is 6th feb 14 minus 6 days
step 2- add the values of column I which correspond to all the dates that fall within 6th feb 14 to 31st jan 14
step 3- indicate the sum in column K
Unfortunately i cannot include any pictures or files to show what i have mentioned due to site limitations.

Resources