How to add cells consecutively after an interval of three cells - excel

I have 18 years of monthly data i.e., I have 18*12 = 216 cells arranged in a row. I have to add JJAS (June 01 July 01 August 01 September 01) and then ONDJF (Oct 01 Nov 01 Dec 01 Jan 02 Feb 02) values. I want to skip MAM. I have to repeat this procedure for all 18 years.
I can do this manually but want to automate it.
I want JJAS 01 ONDJF 01-02 JJAS 02 ONDJF 02-03...

If Column B contains dates and Column C contains text then putting this formula in Column A will result in Column A having text for JJASONDJF and empty cells MAM.
=IF(OR(MONTH(B1)<3,MONTH(B1)>5),C1,"")
If dates are in Row 2 then putting this formula in Row 1 will display the date.
=IF(OR(MONTH(A2)<3,MONTH(A2)>5),A2,"")

Related

How to COUNT between a date range if nested within another formula?

I am trying to substitute '!!!!!!' for a formula to count the number of W in column P on sheet TRADE LOG between the dates of 01 Feb 2021 and 28 Feb 2021 in hardcoded format.
This is the current formula :
=IF(COUNTIFS('TRADE LOG'!P:P,"W",'TRADE LOG'!B:B,">="&DATE(2021,2,1),'TRADE LOG'!B:B,"<="&DATE(2021,2,28)),"!!!!!!","")
Could anyone suggest what needs to be added in order to achieve this?
To make this clearer, I want F16 in STATISTICS to count the number of W's in sheet TRADE LOG column P between the dates of 01 Feb 2021 and 28 Feb 2021. However, if there is none I would like F16 to return a blank.

What is the best way to use Index Match in this case?

In the primary worksheet, I have a list of employees in column A, from columns D:ZZ I have basically a calendar in row 11. Where these intersect, I have assigned a task code to each employee to illustrate what they are employed to do that day. I want to dynamically color the coded cell based on the date in the row 11 and code from the column that it was entered. In my second sheet, I have a table of the codes along column A. From columns B:AM, in row 2 (under the header) I have another code that says what type of work it is, in office, on the road, etc. This is the code I am trying to look up with Index Match. In the row with the task code, under each header I have a scheduled date that that particular job will be either in or out or nothing.
I can Index the task column pretty easily, my problem is how would I take the row I get from that, then search only that row for the date that I applied the code to the employee to return the result from row 2 and the column that that date appears?
I have a pretty good understanding of Index/Match in looking up multiple items to return a result. I am having a problem creating a range from a result to find the data I want.
I have tried Indirect and Address as well as Offset, but I don't want this to be volatile as it is being used in conditional formatting over several thousand cells.
Task Code Schedule Worksheet
DAY 1 2 3 4 ...
CODE A S A F ...
96T003 03 May 04 May 05 May 06 May ...
96T004 05 May 06 May 07 Jun 10 Jun ...
96T005 05 May 19 Jul 22 Jul 23 Jul ...
Primary worksheet
SAT SUN MON TUE WED
DATE 01 02 03 04 05
JONES OFF OFF 96T003 96T003 96T004
DAVIS OFF OFF 96T003 96T003 96T005
This formula works, but is "volatile" and I am leary to use it in a conditional formatting function. Is there a way to make it not as volatile?
=INDEX(CMP_FLYCODE,1,MATCH(F11,INDIRECT("'CMP'!"&ADDRESS(MATCH(F19,CMP_ADP,0),1)&":"&ADDRESS(MATCH(F19,CMP_ADP,0),40)),0))
CMP_FLYCODE is a reference to just the A, S and F code row
Expecting to return a letter code A, S or F based on the date and code
Edit: Added the header to the code schedule that is a unique number for the day of the task 1, 2, 3...
I don't think it's too bad, you can just get the entire row from the 2d array B3:E5 in the task sheet using index with the match for the task code in the row parameter and 0 in the column parameter, then match the date in that and use index again to get the required letter code.
This is what my formula looks like:
=IF(C3="OFF","",INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0)))
This is my primary sheet:
This is my task sheet:
So to use this in conditional formatting, you would need three rules using custom formulas
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="A"
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="S"
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="F"
with appropriate fill colours.

How to Drag a formula in Excel both across the columns and rows?

I have an Excel 2007 file with 2 sheets. The first sheet has 2 columns: one of dates, one of numbers like so:
1/1/2017 37
1/2/2017 82
1/3/2017 96
...
The second sheet has is to store the numbers in a "Calendar-like" fashion, like so:
SUN MON TUE WED THR FRI SAT
1/1/2017-1/7/2017 37 82 96 23 54 25 97
1/8/2017-1/14/2017 49 76 65 13 12 14 96
...
I am filling the "Calendar" style sheet from the much larger "List" style sheet. These go on for years, so I need a simple way to fill the "Calendar" style sheet from the plain list. I can use the simple formula of =sheet1!D7 to get from one sheet to the other, but I can only drag that formula in one direction... I can start it on Sunday, Jan 1 and drag it the whole way to Saturday, Jan 7, but if I try to drag the formula from that row to the next, it tries to insert starting with Jan 2 instead of Jan 8:
SUN MON TUE WED THR FRI SAT
1/1/2017-1/7/2017 37 82 96 23 54 25 97
1/8/2017-1/14/2017 82 96 23 54 25 97 61
...
Can I get these values from the list-type sheet to the calendar-type sheet without typing the formula in for each and every cell?
Not sure how your data is laid out, but if you adjust the range, this index/match should work:
=INDEX($B$1:$B$31,MATCH(DATEVALUE(LEFT($E3,SEARCH("-",$E3)-1))+COLUMN()-6,$A$1:$A$31,FALSE))
Note: I have one magic number in the formula, a 6. This is because this is where your "Sun" column starts. If you put your formula in any other column, adjust that number. Alternatively, you could get fancy and add logic looking for "Sun" in some array, but thought that's a little overkill.
You can drag this formula over and down.

adding a value for X number of rows and then another value for the next x number of rows

Here is an example of my database:
id year birthday ...
1 1995 10 Oct 1990 ...
1 1996 10 Oct 1990 ...
1997 10 Oct 1990 ...
2 1995 01 Aug 1988 ...
2 1996 01 Aug 1988 ...
2 1997 01 Aug 1988 ...
3 1995 21 Mar 1987 ...
1996 21 Mar 1987 ...
1997 21 Mar 1987 ...
The id is a number identifying and individual. The database is longitudinal therefore there are multiple collection dates, which I have called year. I have had to compile this data from different databases containing the information so some of the id numbers are not entered but I want them to be. For example, individual in this database is missing the id number for 1997 and the third individual is missing it for 1996 and 1997. Is there a way to add these values by using a formula? I have data of about 300 individuals over 13 years, so I don't want to enter them manually.
I have not seen enough of you data but I think a macro would be more suitable
Sub FillInEmpties()
Dim i As Long
Dim lr As Long
lr = Range("B" & Rows.Count).End(xlUp).Row
Dim cell As Range
For i = 1 To lr
Set cell = Range("A" & i)
If IsEmpty(cell) Then
cell = cell.Offset(-1, 0)
End If
Next i
End Sub
because you would have to enter the formula in each of the empty cells which is not really an efficient way of doing things.
An alternative would be to compare the years and then fill in column A based on year difference
example
stick this in A3 and drag it down
=IF(B3>B2,A2,A2+1)
I am not sure if you need to do this one-time or regularly, and this might belong on SuperUser but here's one code-free method:
Select Column A.
Press Ctrl + G to bring up GoTo and then select Blanks.
This will select the cells you wish to fill in.
In the formula bar, enter the cell above the first blank cell selected, for example below, the first blank cell is A4, so I entered =A3.
Press Ctrl + Enter and the formula will be copied to the previously blank cells.
Copy-paste as values and you're done.

Select rows from sheet1 & display in sheet2

In Row1 on sheet1 I insert ID, Description, Amount
ID will have values such as:
01
02
03
01
02
04
01
On a separate sheet I would like to show only the rows which have ID 01.
I would like this automatic, without using filter, or VBA
Is there any particular equation?
I believe dLookup should do the trick

Resources