how to get next non empty cell value in an excel column - excel

Here is my excel looks
Column A Column B
1/1/2016
2/1/2016
3/1/2016
4/1/2016
5/1/2016
.
.
.
31/1/2016 1000
Now I will be referring one of the date in this month on another sheet and I would like to pull Column B value corresponding to last date on each month. There wont be any value till last date on column B.
Any hint to do this ?

First step is to make the condition:
=IF(A1=EOMONTH(A1,0),B1,"")
Note: if date in A1 is really the end of its month, it takes result from B1
Second step is to combine it with Vlookup. I assume that you would input some date in column C:
=IF(C1=EOMONTH(A1,0),VLOOKUP(C1,$A$1:$B$1000,2,FALSE),"")
Third step is... you can change the formula if your input is in another sheet. For the example: the data are in "sheet1" and the date input are in column C at "sheet2":
=IF(C1=EOMONTH(Sheet1!A1,0),VLOOKUP(C1,Sheet1!$A$1:$B$1000,2,FALSE),"")
Hope it'll help.

Related

How to assemble Offset function with Condition?

I Have date data in Column A and values data in Column B.
My aim goal is that for each date in column A :
look if one value (column B) during 1 year is less than 90% of the corresponding Value of the date.
This is my data:
Output example :
I start at the first date (31/12/1986) and see the 900.82 value.
I calcul 900.82 * 0.9 = 810.73
So i look if value in line 3 is inferior to 810.73,
If not
I look if value in line 4 is inferior to 810.73,
line 5, 6, 7 ,8..... during 1 year (that mean I stop this the 31/12/1987).
If it is
I stop and i look the next date (01/01/1987) and do the same.
I am agree to translate it in VBA code, but it could be better on Excel.
I first tried an algo to understand the problem :
-Look the first date in column A
-Look the corresponding value in Column B and save it as Value
-Offset to the next date in column A
-Look the corresponding value in Column B and save it as Range.to.compare
-If Range.to.compare < Value * 90% then write "ok" in Column C
-Else, Offset to the next date in column A...
-Untill 1 Year (Untill Year(Date in Column A)<Year(Date in Column A) +1
I try to translate it in Excel or VBA.
This this what I tried by Excel :
But it works only for 1 day instead of 1 year
I think this is what you're after. I broke the calculation into multiple columns to show the steps.
First I calculate the 90% value, in column C.
Column D is where most of the magic happens. In column D I find all rows that have a date < the current date + 1 year, and get the value (Col B) for each of those rows. I then take the minimum of all those values. Note this is an array formula so you need to press shift-ctrl-enter after you type it in.
Now that I have the minimum from the each range, I just need to compare that with the 90% value.

Count cell per month

I look for a code for the number of times a value is in a cell, on a monthly basis
So
1-1-19 KS
2-1-19
3-1-19 KS
.
.
1-2-19 KS
2-2-19
3-2-19
January 2
February 1
is this possible?
Assume that your dates are in column A, your KS is in column B.
In cell D1:D12 you have the first of each month entered and given a custom number format of mmmm so it just shows January, February, etc.
The formula =MATCH($D1,$A:$A,0) will give the row number that the month starts on.
For simplicity I'll call this Start_Row.
The formula =MATCH(EOMONTH($D1,0),$A:$A,0) will give the row number that the month ends on.
I'll call this End_Row.
The formula INDEX($B:$B,Start_Row):INDEX($B:$B,End_Row) will set a reference in column B to all rows between the first of the month and the end of the month.
I'll call this CountRange.
Now you just need to count what's in that reference using either:
=COUNTIF(CountRange,"KS") to count just KS
=COUNTA(CountRange) to count any non-blank cells.
So the full formula, without any helper columns, would be:
=COUNTIF(INDEX($B:$B,MATCH($D1,$A:$A,0)):INDEX($B:$B,MATCH(EOMONTH($D1,0),$A:$A,0)),"KS")
Keeping in mind that D1 contains 01/01/2019

VBA, change part of date in cell

I have a large sheet of data where i need to change the date (day) in 4 or 5 columns to match the date (day) in another column. For example in 'H' i have 16/05/15 etc. and in the other columns all the days are the 1st of the same month. I would like to change the day '1' to the same day '16' as in column 'H' it will take me hours to do, can anyone help me out with some code that would do it for me?
Thanks.
If this is a one-off, you could just write a formula in a temporary column that calculates DATE using the YEAR and MONTH of the original cell and the DAY of column H (watching out for 29th of Feb in non-leap years, if the year in H is different to the year in the other cell), and then "paste values" that result back over your original cells.
For example, assuming data you want to change is currently in K2, then place the following formula in X2 (or wherever else you like):
=IF(MONTH(DATE(YEAR(K2),MONTH(K2),DAY(H2)))<>MONTH(K2),
DATE(YEAR(K2),MONTH(K2)+1,0),
DATE(YEAR(K2),MONTH(K2),DAY(H2)))

excel extract 6 digits from number, format as date and match with index match?

I have the following 2 worksheets.
Data:
Column B Column C Column D COLUMN E Column F
329115121601 3291 5555 =Date (MID(B8,9,2),MID (B8,7,2),MID (B8,5,2)) 50 <---- Week Number from date
I am trying to extract 6 digits from my number value in Columb B '151216' and want to put this into column E. The 6 digits represent a date which is 15th December 2016.
I am using mid to try and get the number and then date to try and format this as 15/12/2016 - however it's not working. Instead I get 15/12/16.
On my other sheet, 'Home' i am trying to look up the number from column B on sheet 'Data' using an index match (array formula) where the values in column C, D and E or F match.
Home:
Column H Column I Column J Column K
3291 5555 15/12/2016 or Week 50 {=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}
The user should be able to enter either week number or a specific date and get a result.
For some reason, this formula works if the user enters a week number, but not if they enter a specific date. I'm not sure if this is a format issue with the date on sheet 'data' or with the index match formula. Please can someone show me where I am going wrong? Thanks
Excel defaults to 1916 when I input your formula, try adding "20"& to the start of the year parameter:
=Date("20"&MID(B8,9,2),MID(B8,7,2),MID(B8,5,2))
I think you are doing it well. Just need to format the date.
Right click on the cell that contains the date ( 15/12/16 ) then click on cell formatting option and choose the format you prefer.

Excel - CountIfs using column header and value from other column as criteria?

I am trying to produce a countifs formula to put in a cell on sheet 1, that will count the number of entries for ID 'A' on sheet 2.
But also i need to add a criteria to say only count the entries where the date in the column header on sheet 2 matches the date in the column header on sheet 1.
Sheet1
ID 01/01/2016
A 1 (Formula goes here)
B 0 (Formula goes here)
C 1 (Formula goes here)
D 1 (Formula goes here)
Sheet2
ID 01/01/2016
A 1pm - 2pm
B
C 1pm - 2pm
D 1pm - 2pm
I am really struggling to get this to work. so far i have put together this, but it doesn't have the criteria for the dates.
=SUMPRODUCT((Data!$A$2:$A$1000=$A2)*(Data!$D$2:D$1000="$D$1"))
Please can somemone show me where i am going wrong?
Try something closer to,
=SUMPRODUCT(($F$2:$K$9<>"")*($F$1:$K$1=$B$1)*($E$2:$E$9=$A2))
I've put everything on one worksheet but you should have no trouble splitting it off to Sheet2.
      

Resources