Match, pull and add numbers from different cells on a different sheet - vba

I have data on 'JobSheet1' in Column D, I have Invoice Numbers in ascending order (some are repeated for different products on same order), in Column E, I have amounts i.e £50.00.
On a second sheet 'InvoicesSheet1' in Column B, I have the invoice numbers and Column C is where I would like the total for each invoice number to appear.
Can anyone help with very simple VBA or a formula that will search for the Invoice Number its sitting by in 'JobSheet1' Column D and add all the matching invoice number totals from Column E.

Scott Craner is right, with the schema you described, you will get the result you want entering into cells Ci:Cj (where "i" and "j" are
the start and end of your table, respectively):
=SUMIFS('JobSheet1'!E:E,'JobSheet1'D:D,B{i...j})
If this doesn't work, likely issues you need to watch out for would be:
Sheets are not named exactly as you typed here. Maybe they have a leading or trailing space.
Your copy of Excel/Windows may be set with a different regional setting, which requires that formula parameters be separated by semicolons (;) instead of comas.
Your invoice numbers may not be typed precisely the same in the two different formulas.
Your amounts in column E may not be stored as numeric values. You can test for this by selecting a few values from column E - if excel doesn't show their sum and average in the bottom right corner, they are stored as text and you can't perform math operations on them.
I'd need to see your data to see what could be the issue, but that's not what this forum is for - Try constructing a new table with dummy data set up exactly as you described it here and try using this formula, to verify if it works. Then, adjust accordingly as needed.

Assuming you're first invoice number in InvoiceSheet1 is in cell b3, you can use:
=SUMIF(JobSheet1!D:D,InvoiceSheet1!B3,JobSheet1!E:E).
If it's in another row, replace InvoiceSheet!B3, with the relevant cell where your data starts. Copy down the formula for the other invoices
SUMIFS is not necessary with just one lookup condition.

I solved this by amending the SUMIFS suggestion from ScottCraner and this is what I ended up with
=SUMIFS(Jobs!K:K,Jobs!A:A,D3)+SUMIFS(Jobs!L:L,Jobs!A:A,D3)
Does the job!

Related

How do you select irregular duplicates with Google Sheets queries?

I have a Google sheet with 186,000 rows. I have included a dummy spreadsheet to give you an idea of the data. I need to select ALL duplicates, that includes rows where the first names might not match (i.e. Cathy vs Catherine), but they still refer to the same individual. There are also instances where the addresses might be slightly different (like omitting "Ave" in one row but including it in another).
I need to write a query to account for all of these instances, including just regular duplicates. Or I could do multiple queries and just copy the results into one spreadsheet. In any case, I'm at a loss.
Dummy spreadsheet. I have included one example of each case I am trying to account for (3 total).
I have something that may be useful. See my example sheet here:
https://docs.google.com/spreadsheets/d/19h28go-nzunW6zexcMD61QjySUKJA3Q2Ci2Hu3OMuAg/edit?usp=sharing
Basically I build a key value for each record, along the lines you asked for.
All of the last name, part of the first name, part of the address, and the ZIP code. Other variations are easily added.
The formula is just a string concatenation of parts of these fields, as follows:
=ArrayFormula(
IF(ROW(A2:A)=2,"DupeKey",
IF(A2:A<>"",A2:A &LEFT(B2:B,$N$1) &LEFT(G2:G,$N$1) &K2:K,"")))
A valuable option is to allow varying the length of the required matching sub-string, from the first name and address. This is controlled for the formula by selecting a substring length of 1 to 6 in cell N1, and seeing how this changes the duplicate records that are found. The shorter the substring length, the more duplicate (or possibly duplicate) records will be found.
Conditional formating is used to highlight the duplicate records.
And you can use the column filters to sort by different data columns - to put all of the duplicates at the top, sort by column N, in Z-A order, and exclude blanks.
Note that this isn't perfect. If someone accidentally types a space, or anything else, at the start of a data field, it will not be considered a duplicate. Better logic would be required to catch those.
Let me know if this helps.
You can use these formulas:
If cell B3 match "John" write "match", if doesn't match write "no"
=IF(REGEXMATCH(B3,"John"), "match", "no")
If cell F2 contains content of cell B3, write "match", if doesn't match write "no"
=IF(SEARCH(B3, F2)>0,"match","no")
References:
REGEXMATCH
SEARCH

Find first non-blank cell in column that meets criteria in another column

I've compiled multiple spreadsheets containing sporadic employee information, and I'm now trying to consolidate all of the information to remove duplicates and blanks. The formula below is my starting point, but if the first cell that meets that criteria is blank, it returns a blank. I want it to find the next cell that meets that criteria but has a value.
=INDEX(Working!C:C,MATCH($A3,Working!$B:$B,0))
Below is what the Working tab looks like, which contains the master list of data including blanks and duplicates. Working!C:C is the list of last names; $A3 is the Employee ID I'm hoping to retrieve data for, and Working!$B:$B is the list of Employee IDs. I'll be doing this for many columns, so to illustrate this, in the table example below I've shown that Column D is the phone number. Any help you can provide is appreciated!
Column B-------C-------D
---------287-----Doe----blank
---------287-----blank---333-333-3333
---------287-----Doe----blank
Use the following array formula:
=INDEX(Working!C$1:C$100,MATCH(1,($A3 = Working!$B$1:$B$100)*(Working!C$1:C$100<>""),0))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
Please note that with an array formula the references need to be the smallest range possible that covers the dataset.

Text Manipulation nestled within a Query (Or ArrayFormula) (Google Sheets)

I'm trying to Query some data in my spreadsheet, returning a manufacturer based on product code. We code our products with a three digit suffix that corresponds to different customers. I know the codes but people viewing the sheet may not.
Right now, I'm trying to split the suffix from the product and perform the wuery in the same formula.
I can do this in two steps, splitting the suffix from the code and querying just the suffix, but I want to know if I can do this all in one code. My current formula returns the data I want but it does not fill the entire range of the sheet. I would rather have this happen automatically as the workbook will be dynamic.
My current formula is:
=QUERY(CxSeries,"select B where C CONTAINS '"&right(Code,3)&"' ")
https://docs.google.com/spreadsheets/d/190kom4q0XOJP4UdLTJpZf5tuJCQTflcuokRp_FJ4pBc/edit?usp=sharing
I'm not sure if query is the right way to go about this, but I'd prefer to stick to that (just because i honestly can't wrap my head around ArrayForumlas).
Thank you,
Clear all formulas you have in column C and enter in C7
=ArrayFormula(vlookup(regexextract(D7:D16,"-(\d+)$")+0, {Sheet5!C6:C,Sheet5!B6:B}, 2, 0))

Finding string and returning information from an adjacent cell

Using Excel 2010. I need to see if a string in one set of cells exists in another set of cells, and if so, return information from the adjacent cell that matched that string. I had originally done this with SEARCH, ISNUMBER and nested IF statements, but my source data set has several dozen entries in it, and the strings that must be searched has several hundred entries. The data resembles that in the picture (a simplified example):
For a limited data set, I used nested IF statements, like:
IF(ISNUMBER(SEARCH($D$2,$A2,1)),"Cat Info",IF(ISNUMBER(SEARCH($D$3,$A2,1)),"Dog Info",IF(ISNUMBER(SEARCH($D$4,$A2,1)),"Elephant Info","Not Found")))
But now both sets of data are too large to do that on.
What I need to do is to search the strings in column A for the keyword in column D. If the keyword is found, I need to return the corresponding information from column E.
For example, in column B2, since the word dog is in A2, I would want the contents of E3 (Dog Section) to be displayed in B2.
My list of keywords are unique (Column D, List) and I know that zero or one keyword will appear in the string in Column A (TheString).
I think that INDEX & MATCH functions may be part of my solution, but I am unsure how to find which List keyword is in the string and then return the Information column value.
No need for VBA. This can be done with a simple formula:
Enter this formula in cell B2:
=LOOKUP(2,1/SEARCH(D$2:D$7,A2),E$2:E$7)
Copy downward as far as needed.
Note: adjust the range references to the size of your data.
Not done it all, but this formula
=MAX(IF(ISNUMBER(SEARCH(D1,$A$1:$A$4,1)),ROW($A$1:$A$4),0))
Array Formula
Will give you the row of the A1:a4 where D1 etc, is contained. Then you can index on that. However it will only show the max row, so if its in 1 & 2, then it will only show row 2.
Cheers.

Copy matching cells based on one column

Please see here for snippet from my spreadsheet, what I am trying to do is fairly simple, however I am unable to find a way to do this after searching through online forums extensively.
Column A contains my order numbers and column B the line items that correspond to each order number.
Column D contains the delivery date as it appears on my printed order sheet, you will see this only pulls through for the first line item on each order - the raw data displays this way and so there is way to change the raw data
Column E simply extrapolates just the date rather than the format Delivery Date: dd/mm/yyyy.
What I would like then, is for column E to have the delivery date copied down to all corresponding cells for each order number - so as per the attached sheet, 30 Jul 2015 would appear for all line items that correspond to order no #1192.
I feel v look up etc will only work to manipulate data once I have these dates copied down. I have tried index match but it doesn't seem to do what I want it to do.
Is there a way to copy down the dates for all line items relative to their order number? I understand that it will probably require copying full lines down column D first and keeping the formula in column E to extrapolate just the date.
Any help is much appreciated
You don't need a macro for this. There are many ways to go about this, I'll show you two, you can figure out the one you like from there.
Select coloumn E, go to Home, Editing, Find & Select, Go To Special. Hit Formulas (if the values are not formulas, go for Constants), and check only Errors. Now type =E2 (or whatever is above your active cell), and hit Ctrl+Enter. It is a wise idea to copy-paste values the whole coloumn E after this.
Another way would be entering this formula in coloumn F (cell F2, then pull it down):
=IFERROR(E2;F1)
Or you could combine this with your original formula, or use a macro to insert the formula in the empty/#error cells etc...
Assuming you are using =RIGHT(D2,LEN(D2)-FIND(":",D2)-1) in E2, then you are well on the way to a solution.
You also mentioned INDEX/MATCH which, if used in column F will pull the Delivery Date in Column E for each Order No:
=INDEX($E$2:$E$31,MATCH(A2,$A$2:$A$31,0))
This finds the position of the first match for your Order No and returns the Delivery Date from column E.