I am having an issue with vlookup using 2 columns. I have the following 2 columns in my base excel sheet
ID_1 ID2
2 4
7 9
and my target sheet has these values
ID spend
2 20
4 30
7 10
1 5
9 10
When I run my vlookup, I would like to get this result
ID_1 ID2 Total_Spend
2 4 50
7 9 20
I am using something like this for Total_Spend, but it is not working..
=iferror(vlookup,0)+iferror(vlookup,0)
In this case you can use SUMIF()
Here the formula in D4 is:
=SUMIF($B$9:$B$13,B4,$C$9:$C$13)+SUMIF($B$9:$B$13,C4,$C$9:$C$13)
Related
I have an Excel Workbook with 2 sheets. Each sheet contains a formatted table.
The tables start at row2 and feature an internal numbering in columnA achieved by the formulas
=Row()-Row(talble1)+1 and =Row()-Row(talble2)+1
sheet2:
In table2/columnB I concatenate 2 of the internal row indices from table1 using the formulas
table2/internal row1: =CONCATENATE(sheet1!A2;";";sheet1!A3;";")
table2/internal row2: =CONCATENATE(sheet1!A4;";";sheet1!A5;";")
table2/internal row3: =CONCATENATE(sheet1!A6;";";sheet1!A7;";")
table2/internal row4: (...)
It looks like this:
sheet1/table1: sheet2/table2:
A B C A B C
1 1
2 1 2 1 1;2
3 2 3 2 3;4
4 3 4 3 5;6
5 4 5
6 5 6
7 6 7
8 8
9 9
If I "manually" delete the 2 rows with internal indices 3 and 4 in table1, the numbering automatically adjusts. Also, the references in internal row2/columnB of table2 become invalid, which makes total sense. The formula of internal row3 in table2 automatically adjusts to the deletion in table1 and remains valid.
It then looks like this:
sheet1/table1: sheet2/table2:
A B C A B C
1 1
2 1 2 1 1;2
3 2 3 2 invalid
4 3 4 3 3;4
5 4 5 4
6 6 5
7 7 6
8 8
9 9
Now comes the issue:
If I do the deletion described above using a VBA macro, the references in internal row3 of table2 become invalid as well! When I check the formula I see that it still references cells A6 and A7 which don't exist anymore in table1.
I used the code
sheet1.ListObjects("table1").DataBodyRange.Rows(4).Delete Shift:=xlUp
sheet1.ListObjects("table1").DataBodyRange.Rows(3).Delete Shift:=xlUp
It looks like this:
sheet1/table1: sheet2/table2:
A B C A B C
1 1
2 1 2 1 1;2
3 2 3 2 invalid
4 3 4 3 invalid
5 4 5 4
6 6 5
7 7 6
8 8
9 9
What is the explanation for the different behaviour of deleting a row in table1 manually or by VBA code?
I also recorded macros when deleting the rows manually and I could not detect anything that explains why my macro code leads to the invalid references in internal row3 of table2.
I have excel sheet with repeating ids
id jun19
1 3
2 2
3 7
1 3
2 2
3 7
1 3
2 2
3 7
i want to append another column 'jul19' from another sheet.
that jul19 sheet has all and even more ids:
id jul19
1 4
2 6
3 45
4 7
5 9
it should take only those that have the id and pull values from column 'jul19'.
the end result is this:
id jun19 jul19
1 3 4
2 2 6
3 7 45
1 3 4
2 2 6
3 7 45
1 3 4
2 2 6
3 7 45
how to do this? how to pull corresponding values from column "jul19" based on the id?
I tried to do this in pandas, but failed.
Assuming table1 is in A1:B10, table2 is in D1:E6, & table3 is in G1:I10. put :
=INDEX(E:E,MATCH(G2,D:D,0)) in I2
and drag downwards. ref : https://exceljet.net/index-and-match
Hope it helps. ( :
I am stuck with a problem. Lets say I have the following data in range A1:K4
row1 1 2 3 4 5 6 7 8 9 10
row2 2 3 4 5 6 7 8 9 10 11
row3 3 4 5 6 7 8 9 10 11 12
row4 3 5 6 7 8 9 10 11 12 13
And the following data in range N1:P4
1 2 3
2 3 4
3 4 5
11 12 13
I want formulas in range R1:R4
The desired output should be R1=1, R2=2, R3=3, R4=1
i am trying to evaluate first set of numbers 1 2 and 3 and check in every row from row1 to row4 and find out how many rows matched all 3 numbers and the put the value in cell R1.. continue this for all 4 sets of number. Can someone help me with a formula?
Thanks
You could use this formula in R1 copied down to R4
=SUMPRODUCT((MMULT(COUNTIF(OFFSET(B$1:K$4,ROW(B$1:K$4)-ROW(B$1),0,1),N1:P1),{1;1;1})=3)+0)
although I've cheated a bit, there, because {1;1;1} is variable based on the number of columns in N1:P1 (and so is the 3), so for a more generic version (which would allow N1:P1 to be any size row) you can use this "array formula"
=SUM((MMULT(COUNTIF(OFFSET(B$1:K$4,ROW(B$1:K$4)-ROW(B$1),0,1),N1:P1),TRANSPOSE(COLUMN(N1:P1)^0))=COLUMNS(N1:P1))+0)
confirmed with CTRL+SHIFT+ENTER
In Excel, I have an hours log that looks like this:
PersonID Hours JobCode
1 7 1
1 6 2
1 8 3
1 10 1
2 5 3
2 3 5
2 12 2
2 4 1
What I would like to do is create a column with a running total, but only within each PersonID so I want to create this:
PersonID Hours JobCode Total
1 7 1 7
1 6 2 13
1 8 3 21
1 10 1 31
2 5 3 5
2 3 5 8
2 12 2 20
2 4 1 24
Any ideas on how to do that?
In D2 and fill down:
=SUMIF(A$2:A2,A2,B$2:B2)
Assuming that your data starts in cell A1, this formula will accumulate the hours until it finds a change in person ID.
=IF(A2=A1,D1+B2,B2)
Put the formula in cell D2, and copy down for each row of your data.
I need to determine the range to apply the Frequency function. Here's what the problem is. On the given sheet, I have subtotals for my data and there is a column which has "Stop" Values.
The data would look something like:
Route1
Order# Stop# Qty
001016 1 5
008912 1 5
062232 2 6
062232 3 2
069930 4 1
1000 4 3
1001 4 4
1001 5 8
1003 8 1
Route 1 Subtotal 6 35
Route2
Order# Stop# Qty
10065 1 5
10076 1 5
10077 2 6
10079 3 2
10087 4 1
10098 4 3
10109 4 4
10171 5 8
10175 8 1
Route 2 Subtotal 6 35
How do I write VBA code for calculating the distinct stop values. I need the distinct count of the stop#. Hence in the example above you can see that the total stops are 6 because 1 stop can have multiple orders and 1 route can have multiple orders/stop. Hope I am making sense here. Let me know how I would write my VBA code for this. Thanks for your help.
For the Stop Subtotal unique count, try this formula (adjust ranges as required):
=COUNT(1/FREQUENCY(B2:B10,B2:B10))