I have a column of dates that are in the format: yyyymmdd.
An example is shown below:
19480110
19480111
19480115
19480119
19480124
19480130
19480131
19480201
19480204
19480209
19480210
19481225
19481226
19490212
19491210
19500108
19500208
I would like to be able to identify ONLY the cells that have 3 OR MORE consecutive dates. In this case, the cells with the following values would be highlighted:
19480130
19480131
19480201
Currently, I have a formula of the form:
=IF(A2=A1+1, "Match", "")
However, it fails to recognize instances when there is a change in the month, as in the case of this example: It only prints match next to the cell that has '19480131' in it. Is there a way to account for changes in months with the present formatting?
Thank you!
You need to convert the date text to a date value, e.g.
=IF(DATE(VALUE(LEFT(A2,4)),VALUE(MID(A2,5,2)),VALUE(RIGHT(A2,2)))=DATE(VALUE(LEFT(A1,4)),VALUE(MID(A1,5,2)),VALUE(RIGHT(A1,2)))+1, "Match", "")
With data in column A starting at A2, in B2 enter:
=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))
and copy down. This converts to real dates. then in C2 enter:
=B2-B1
and copy down
If there are two consecutive 1's in column C, we have a consecutive triplet (at least). So in D2 enter:
=IF(OR(AND(C2=1,C3=1), AND(C2=1,C1=1), AND(C4=1,C3=1)),"*","")
How about =IF(A2=A1+1, "Match", IF(AND(OR(MOD(A1, 100) = 31, MOD(A1, 100) = 30, MOD(A1, 100) = 29, MOD(A1, 100) = 28), MOD(A2, 100) = 1), "Match", ""))
Having said that, there is a caveat that if you have Jan 28 and then Feb 01 it will say that is consecutive where you know it is not. If you want something that doesn't have that issue, I can code that.
Related
I am trying to get G19 in sheet STATISTICS to only populate with data calculated from the COUNTIFS formula shown below when F19 of sheet STATISTICS has data within. If there is no data calculated for F19(i.e. an empty cell returned) (separate formula) then G19 should return a blank.
The COUNTIFS formula shown is counting the amount of L's within column O on sheet TRADE LOG between the dates of 01 Feb 2021 and 28 Feb 2021.
This is the formula I am currently using in G19 :
=IF(COUNTIFS('SHARES LOG'!O:O,"L",'SHARES LOG'!B:B,">="&DATE(2021,2,1),'SHARES LOG'!B:B,"<="&DATE(2021,2,28)), COUNTIFS('SHARES LOG'!O:O,"L",'SHARES LOG'!B:B,">="&DATE(2021,2,1),'SHARES LOG'!B:B,"<="&DATE(2021,2,28)),"")
If anyone could tweak this to make it produce the data as detailed above that would be great.
As F19 returns "" in the second part if the IF(...) then you can't test using ISBLANK(F19), so I would use the following (indented for clarity) for G19, basically wrap the original formula inside IF(TRIM(F19)="", "", ... original ... ):
IF(TRIM(F19)="", "",
IF(COUNTIFS('SHARES LOG'!O:O,
"L",
'SHARES LOG'!B:B,
">="&DATE(2021,2,1),
'SHARES LOG'!B:B,
"<="&DATE(2021,2,28)),
COUNTIFS('SHARES LOG'!O:O,
"L",
'SHARES LOG'!B:B,
">="&DATE(2021,2,1),
'SHARES LOG'!B:B,
"<="&DATE(2021,2,28)),
"")
)
I'm using a vlookup against a table that has a generally-formatted column in the format "WORD NUMBER DATE" such as "Romeo 5M 06/16/2019". The reference is a helper column that I've created combining "Romeo" and "5M" and "06/16/2019". However, the date part needs to be formatted as text or else it won't match the lookup. This formatting is causing the #N/A error, despite a match. When I use =cell=cell2, it brings up "FALSE", given the formatting.
Help with this?
Thanks in advance.
I've already tried copy/paste formatting, and typing out the text in the cell makes the reference work so I'm assuming it's the formatting.
You can format the date in three separate cells. Assuming your date is in cell A1:
In Cell B1 - get the Year value
=YEAR(A1)
In Cell C1 - change the value to 2 digits if the month value is only 1:
=IF(LEN(MONTH(A1)) = 1, "0" & MONTH(A1), MONTH(A1))
In Cell D1 - change the value to 2 digits if the day value is only 1:
=If(LEN(DAY(A1)) = 1, "0" & DAY(A1), DAY(A1))
Then, in your aggregation formula, combine them like this:
= C1 & "/" & D1 & "/" & B1
If I'm reading your question correctly this should solve your issue.
Alternatively, if you need to change the cell format to text you may need to use vba code to perform some calculations for you which I can outline for you as well if this solution doesn't help you.
I have the following table and I'm trying to get a formula so that I can get the sum of a center's result between two dates i.e. Sum all numbers for Bunbury between dates 08-05-17 and 06-05-17 (Result: 950). I've used the following formula but it gives me #VALUE!
My formula:
=SUMIFS(INDEX(B:G,MATCH("Bunbury",$A15:$BC15,0),0),$A$16:$A$21,"<=" & $J3,$A$16:$A$21,">=" & $I3)
enter image description here
Your match should match the column, not the row in B:G.
=SUMIFS(INDEX($B$16:$G$21, 0, MATCH("Bunbury", $B$15:$G$15, 0)), $A$16:$A$21,"<="&$J3, $A$16:$A$21,">="&$I3)
'alternate
=SUMIFS(INDEX($B:$G, 0, MATCH("Bunbury", $B$15:$G$15, 0)), $A:$A,"<="&$J3, $A:$A,">="&$I3)
There's also no need to look further than column G for a match and you should start looking in column B; e.g. $B15:$G15. J3 should be the end date and I3 the start date (not evident from your sample image).
I missed one problem the first time around. INDEX cannot reference all of the rows in B:G; it can only reference the same number of rows as $A$16:$A$21 (the date comparison range). Alternately, if there is no rogue data that would skew results, the date comparison ranges could be made full column. They have to be comparable ranges.
I have several worksheets with data that changes each month in new rows. After entering all of the data, I run various analyses that pull specific data from the worksheets. For example, one such analysis looks like:
=MeterReadings!K27-MeterReadings!K26
The columns ("K") do not change, but the rows increase by one each month.
Is there a way that I can simply specify a new row number-- e.g. "x" and "y" -- and have all of the analysis formula automatically regenerate.
Current month: x= 27
Prior month: y= 26
Then
=MeterReadings!K"x"-MeterReadings!K"y"
What you're looking for is the INDIRECT function. It allows you to create a cell reference from a regular string of letters and numbers. Your example might go something like:
=INDIRECT("MeterReadings!K" & CountA(K:K)) - INDIRECT("MeterReadings!K" & CountA(K:K)-1)
Lets assume that the cell a1 is for the value x and cell b1 is for value y,
On c1 enter:
=INDIRECT("MeterReadings!K"&B1)-INDIRECT("MeterReadings!K"&B2)
I've simulated my problem.. because my original plan is complex to describe:
I need C4 to be 8 because A2 = A3 = A4, and 5 + 2 + 1 results in 8.
Using this logic, the expected results should be:
C4:8 C6:10 C10:23 C12:23
Well, my problem:
I can't use sumif due after the last day of the month (28, 29, 30 or 31) the next day will be 1 again.
I'm stucked on that. Any help would be appreciated.
Thank you for your time.
If it needs to be in the same table I'd go with:
=IF(C2<>C1,SUMIFS([Number],[Day],[#Day],[Month],[#Month]),"")
Where column C contains the days. This way only the first row will show the sums.
Or you could use an extra table containing Year, Month and day and use:
=SUMIFS([Number],[Day],[#Day],[Month],[#Month])
to collect your data and have it aggregated into one table for further use.
In C2 enter:
=IF(A2=A3,"",SUM($B$2:B2)-SUM($C$1:C1))
and copy down
EDIT#1:
The first part of the IF insures blanks where they are needed. The second part of the IF adds up all of column B, but removes parts of B that already appear in column C
Maybe something like the following. The formula in the first cell is different than the others:
The numbers in between your target cells are still showing - is that a problem?