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

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.

Related

Excel - identify due date based on multiple frequencies of given dates

I have table of frequency with amount:
name start_date end_date frequency(M) Amount
A 11 Nov 22 11 Nov 23 6 220
B 15 Nov 22 23 Jun 23 3 500
and a date table. Is there anyway using Excel formulas to identify due dates of these frequencies and sum up all due amounts, like:
Date Amount
10 May 23 0
11 May 23 220
12 May 23 0
13 May 23 0
14 May 23 0
15 May 23 500
Thank you very much.
u can calculate the dates in the same row. the first date calculated would be referring to the start date and every subsequent dates to be calculated would be based on the previous date calculated
so, if your above first table is put in cells from A1 to E3,
the formula in cell F2 should read as: =IFERROR(IF(EDATE($B2,$D2)>$C2,"",EDATE($B2,$D2)),"")
and formula in cell G2 should be: =IFERROR(IF(EDATE(F2,$D2)>$C2,"",EDATE(F2,$D2)),"")
you will next need to pull formula in cell G2 towards right
and copy and paste formula in row 2 in row 3 onwards
to get sum of all the due amount you may next do a sumproduct function of the dates in formula and the amount column

Excel Conditional formatting on two criteria in a separate table

This is a reporting presentation exercise...
I am looking for the magic to change the colour of the cell without changing the contents of the cell.
I have a type of crosstab table, which has the ROWS individual CustomerIDs, and the COLs as months.
PRESENTATION TABLE
CustomerID
Jan 22
Feb 22
Mar 22
0001
$100
$50
$10000
0002
$1000
$1000
$200
....
....
...
And in a separate table, I have some data which I want to use in a conditional formatting type of way.
LOOKUP TABLE
CustomerID
Period
Label
0001
Feb 22
Applied
0001
Mar 22
Pending
0006
Mar 22
Approved
0009
Dec 23
Pending
Let's say that if the CustomerID and Period in the data table has the label "Applied" then I want that cell in the top table, where CustomerID and Period intersect, to be coloured RED. If it's "Passed", I want it to be coloured green, and so on.
The periods are dates data types. The tables are excel tables.
The dollar value in the cell has nothing to do with it.
I've seen some techniques where a combination of Named ranges and confditional formatting are used, but I'm stumped.
I can put the dollar values in the correct cell by putting a helper column into my source data (the second table) and then doing an xlookup on the combination of the row and col headers, against that helper column.
But then I run out of steam.
END RESULT
CustomerID
Jan 22
Feb 22
Mar 22
0001
RED
BLUE
0002
....
....
...
Conditional Formatting On Two Criteria In A Separate Table
This is what I have tried,
• Formula used in Conditional Formatting for Applied
=COUNTIFS($F$2:$F$5,$A2,$G$2:$G$5,B$1,$H$2:$H$5,"Applied")=1
Special credit to Scott Craner Sir for the above formula
• And for the Pending you may try using SUMPRODUCT() or COUNTIFS() Function as well, both way it works,
=SUMPRODUCT(($A2=$F$2:$F$5)*(B$1=$G$2:$G$5)*($H$2:$H$5="Pending"))=1

Lookup using multiple columns and values

I have a sheet filled with data like below:
Gender MS Age Value
Male Married 21 1
22 2
23 3
24 4
Male Single 21 5
22 6
23 7
24 8
Female Married 21 9
22 10
23 11
24 12
Now there's this other sheet where the user will only be inputting the column "Gender", "MS", and "Age" values and the excel formula should be fetching the associated factor. Please help me with one such formula.
For e.g. If the user puts Male, Single and 23, the formula should return 7.
Here is an example on your sample data:
Formula in G4:
=INDEX(D1:D13,MATCH(1,(ROW(C1:C13)>=MATCH(1,(A1:A13=G1)*(B1:B13=G2),0))*(C1:C13=G3),0))
Enter through CtrlShiftEnter
You can use an array formula for this. I am assuming the blank data under Gender and MS are filled in.
=INDEX(Sheet1!A:D,MATCH(1,(Sheet2!A2=Sheet1!A:A)*(Sheet2!B2=Sheet1!B:B)*(Sheet2!C2=Sheet1!C:C),0),4)
After entering the formula, don't press enter! It is Ctrl+Shift+Enter to make this an array formula.
The formula given compares the values in cells A2, B2 and C2 of Sheet2 with the data held in columns A to D of Sheet1, and outputs the value of the fourth column of the appropriate row.

Sum a column in Excel based on two references in the column and two filter reference columns

I need to sum the valumes of a column, but I need to identify the column based on two values in the column and I have to filter it by the values in two adjecent columns.
Here is an example:
Reference1 Act. Act. Act. ... Bud. Bud. Bud.
Reference2 Jan Feb Mar ... Jan Feb Mar
Reference3 Reference4
CAR BLUE 1 2 3 4 5 6
CAR BLUE 1 2 3 4 5 6
CAR RED 1 2 3 4 5 6
So, I have to add all the CAR & BLUE & Act. & Jan = 1+1 = 2. And similarly for the other columns.
I would like to achieve something as follows:
Reference3 Reference4 Reference1 Reference2 Value
CAR BLUE Act. Jan 2
CAR BLUE Act. FEB 4
The problem I have is that formula to use in the Value column above. I can not do a SUMIFS as the columns in the original source table change. A VLOOKUP don't work as there is no single column for the lookup_value. I thought about using MATCH to identify the column, but as I have two references(1&2) it doesn't work either.
Any ideas on what formula(s) I could use to achive the above.
Thanks
Try making a pivot table from your data (this will not make formulas, though, but will nevertheless give you the desired results).
Here is a simple guide on doing that in Excel 2003 - http://www.techonthenet.com/excel/pivottbls/create.php
You can create a Key in a column:
= Reference3 & Reference4 & Reference1 & reference2
and after use the Subtotal command (Inside Data).
Every time you modify the data, you need to reuse Subtotal

vlook up for multi combination value

Friend.
I have sheet1 like below
Jan Feb Mar Apr
A 10 15 13 10
B 11 11 15 12
C 12 13 15 14
D 12 10 10 15
In Sheet 2! i have 2 scroll scroll down list in cells made by data validation.fist one is in A1 with the values A, B and C, in A2 cell with the values Jan,Feb,Mar.
What i need on this, if i select A and Jan from scroll down list. i need to show the value as '10' in A3 Cell
I tried VLook up with my limited knowlege but i can provide only one value in Lookup value and array.
Please help.
You have to provide vlookup a number of column to return as variable, which you may get as a return value of match function.
Sheet1 has populated range A1:E5, where first row contains names of months (range A1:E1). Sheet2 has only values in two cells A1 and A2.
You need to find in which column of Sheet1 is a month, that is done by
match(a2, Sheet1!A1:E1, 0)+1
and find the value with VLOOKUP.
The final formula would be
=vlookup(a1, sheet1!a1:e10, match(a2, sheet1!A1:e1, 0)+1, false)
EDIT: The first time I messed Sheet1 and Sheet2.

Resources