matching multiple values from separate sheets in excel - excel

I have two sheets of data I need to match and transfer values with.
First two columns 1A & 1B
Column 1A contains all unique numbers (these are invoice numbers that we bill out to our customers)
Column 1B contains revenues when we receive payment for these jobs.
second two columns 2A & 2B
I have started to scan our check reports and transfer the data into a simple two column excel sheet (2A & 2B) Column A contains invoice numbers that are also contained in column 1A, column 2B contains the data I want to be transferred into column 1B for each corresponding match between columns 1A & 2A.
I have done some digging and cannot seem to find a simple solution to my problem.

VLOOKUP is the solution.The formula to do this would go into sheet 1, Col B , Row 2 (Assuming you have a headers in row 1).
=VLOOKUP(A2, sheet2!A:B,2,false)
The formula works like so
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
-lookup_value = a cell you want to lookup
-table_array = a range of columns with the lookup column in col1
-index_num = the column you want to return as an int ( in this case column 2)
-range_lookup = should be false to ensure an EXACT match

Related

How can I average the last n number of rows when using a Average(Index, match formula)?

I have two sheets one has a table with sets across the top of the table and daily km for each set the second sheet has set numbers in column b, I wish to find the daily average for the last 6 months (so 182 days) for each of the sets and return the value in column F.
Sheet 2
sheet 1 - Table
I have used the following formula to average the entire column
=AVERAGE(INDEX(Table1[[H9003]:[H9043]],0,MATCH('FA Forecasts'!B5,Table1[[#Headers],[H9003]:[H9043]],0)))
However I only want to return the average of the last 182 rows of the table to the corresponding set number - and each time a new line is added I only want the last 182 rows.
I'm not sure what I can do to achieve this - any advice would be most appreciated.
If you have Excel 365 you can use this formula:
=LET(indexSetNumber,MATCH([#[Set Number]],tblSheet1[#Headers],0),
filterByDate,FILTER(tblSheet1,tblSheet1[Date]>=LARGE(tblSheet1[Date],cntDays)),
filterBySet,INDEX(filterByDate,,indexSetNumber),
AVERAGE(filterBySet))
I like "readable" formulas - this one reads like this:
indexSetNumber: returns the column index of e.g. H9003 --> 5
filterByDate: returns the rows with Top "cntDays" dates. I am using a parameter cntDays in C2 - for this example I chose 2, but you would put 182.
filterBySet: returns column indexSetNumber from filterByDate
from these values AVERAGE is returned.
This might also work (assuming C2 is =TODAY()):
=AVERAGEIF(Table1[Date],">" & C2 - F2,INDIRECT("Table1["& 'FA Forecasts'!B5 &"]"))
Using AVERAGEIF formula :
Table1[Date] : returns the "Date" table column (sheet 1)
">" & C2 - F2 : "date more recent than Today-182 days"
INDIRECT("Table1["& 'FA Forecasts'!B5 &"]") : returns the table column (sheet 1) which header match with Set Number in the current row (sheet 2)
Basically return the average for kms in the past 182 days for the Set Number of the row.

Merging only one column on matching rows

I have a spreadsheet where I have duplicate records(rows). Typically I have 2 rows per record and I need one. The rows are identical apart from one column. Is there a way to merge duplicate rows based on their ID in Column A but only merge column D
Column B for example as the same number, I don't want to merge this column as it will provide the wrong figure as column D has different words per row.
Data is currently.
Column A Column B Column C Column D Column E Column F
178924 £125 £895 Card 82 92
178924 £125 £895 Stamp 82 92
178927 £11 £85 Card 52 69
178927 £11 £85 Stamp 52 69
Perfect result would be
Column A Column B Column C Column D Column E Column F
178924 £125 £895 Card, Stamp 82 92
178927 £11 £85 Card, Stamp 52 69
You could do the following formula in Column G
=$D1 & ", " & VLOOKUP($A1, $A2:$D6, 4, FALSE)
Where your data is entered into A1.
This will return #N/A for unmatched records (you can use IFERROR to mask this with something else if you require) and a concatenation of Column D as in your expected output for matched records. You can filter the results to remove the unmatched to display your desired result.
This solution only works for the first instance of your ID (assuming only 2 instances of each ID in your question). If you want to delete unmatched rows you would have to use VBA.

How do I split a row of text into different columns according to number of characters using a macro in Microsoft Excel?

I want to know if I can use a macro in Excel to separate data in a single column into different colums according to number of characters. For example, what I have is this in column A
A
AB
ABC
1A
564
8
What I need is this, in colums A, B and C
A AB ABC
8 1A 564
Thanks.
Use the following formula in a new column B next to Column A:
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=1,ROW($A$1:$A$6),99999),ROW()),1),"")
Array Formula press Ctrl+Shift+Enter at the same time
and drag it down, it will write the Values of B whose Length is 1, and when it gives empty it means no more Values with Length 1
Small will find the Cell which length is 1 (Row()=1, 1st cell which length=1, Row()=2, 2nd cell which length =1 ...)
If will return all the rows for the corresponding condition
Index will return the Cell
Iferror return empty "" if no more match
For the second column write 2 instead of 1 in LEN($A$1:$A$6)=2
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=2,ROW($A$1:$A$6),99999),ROW()),1),"")
For the third column write 3 in LEN($A$1:$A$6)=3
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=3,ROW($A$1:$A$6),99999),ROW()),1),"")

Excel Data Manipulation with alphanumberic data

I have two columns in Excel. We can say that column 1 and column 2. Both columns have alphanumeric data i want to minus column 1 from column 2. How can i do that.
Example:
column 1 column two result column
ab ab ad
ac ac
ad
Thanks
There are more sophisticated/cleaner ways to do this, but I'd enter this formula into column C (update your ranges accordingly to capture each list), and then sort the result column:
=IF(COUNTIF($A$1:$A$8,$B$1:$B$4)=0,A1,"")
This compares the list in $A$1:$A$8 to the list in $B$1:$B$4 and places the "differences" in the result column C. I'm assuming that sorting is permissible. But like I said, there are VBA solutions that could do this a little more cleanly.

Structured referencing: sum cells at intersection of current row and some columns

I am using structured tables in Excel 2010.
In table "P" I have multiple columns labeled 1a, 1b, 1c, 2a, 2b, 3a ...
The data are some numeric values.
In table "Q" I would like to have columns labeled 1, 2, 3 and each colum should have a sum of the values of table "P" in the corresponding group of columns. That is:
Column 1 should sum up the contents in columns labeled 1a, 1b, 1c
Column 2 should sum up 2a, 2b
Column 3 should sum up 3a, ...
All this should be done on per-row basis.
As a start, I was trying to actually do something simpler and reference a single cell in the current row. By reading the documentation I tried the following:
=P[[#This Row],[1a]]
but even this is causing some formula error which I don't understand.
Update:
With SUMIF I managed to get very close to what I want:
=SUMIF(P[#Headers]; "1a"; P[#])
and if I could somehow grab the tested header value and plug it into the SEARCH function - I would be able to accomplish what I need.
You could perhaps use SUMPRODUCT:
=SUMPRODUCT((LEFT(P[#Headers],P[#Headers]-1)="1")*P)
(LEFT(P[#Headers],P[#Headers]-1)="1") will return an array which will say what headers in table P has 1 as the first integer. This will then be used to determine which columns in the table to sum up.
LEFT(P[#Headers],P[#Headers]-1) returns the integer from your headers. It basically removes the last character from each header and compares it to 1 in the above case.

Resources