Inserting a blank line for a certain amount of columns only and aligning two sets of columns with diff amounts of row data correctly - vba

Hi Everyone I am hoping someone to help me, it seems like a complicated one to me so lets see:
I have to compare two amounts of information for errors line by line for price differences. The excel document is 15000 rows long so hence why I need a macro! Columns A to I hold the the first document information, then K to Q has the second amount of document info. The comparison needs to happen between Column A and Q which have matching "shipper"numbers. Each shipper number has a certain number of part numbers below it which each contain the info I need to compare. The problem is one shipper may have more or less parts on document one compared to document two so I cant just run a insert line using vba as it will cut document 2 incorrect. Is it possbile 1.) insert a line after each shipper changes in document one by looking at column A (Shipper no) and running it until Col I and at the same time (or after) inserting a blank line for documents two looking at column Q AND is it possible to try match up each shipper so they start on the same line to compare properly without me going through and aligning them up manually??Please see link below for example of what I am saying. If it doesnt work, please let me know and I'll make a plan.
Thank you in advance!
1:

Related

How to write an excel index match formula with varying criteria?

Good day,
I have this index/match formula constructed based on a csv table i donwloaded from our office system and it's working fine:
IFERROR(INDEX('2nd'!$A$1:$D$100,MATCH("Enter BIN 1 Quantity",'2nd'!$B$1:$B$100,0),4),0)
However, I noticed that some tables i donwloaded showed different search patterns . Sometimes it's
"Enter Bin1 Qty"(no space) and there are times its just "Bin 1 Qty" or Bin1 Quantity". How can I make my formula adapt to this varying search criteria?. Your kind help will be much appreciated.
Thanks a lot in advance.
Mike
On this Final Table i will be displaying all the data from index matches formula. Got 2 other sheets, 1st and 2nd where I will paste the downloaded csv tables. 2nd sheet displays the 1st table image i posted here (w/c include the varying description and its equivalent value).
Hi #OverflowStacker, I tried your solution below but its throwing number error. Based on the above tables, here is the formula based on your solution, kindly check any problem in referencing, thanks, appreciate the help in advance (i entered it as an array as you mentioned below)
INDEX('2nd'!$D$2:$D$100,SMALL(IF(ISNUMBER(SEARCH(INDEX($T$2:$T$5,SMALL(IF(ISNUMBER(SEARCH($T$2:$T$5,SUBSTITUTE('2nd'!B2," ",""))),ROW($T$2:$T$5)),1)),SUBSTITUTE('2nd'!$B$2:$B$100," ",""))),ROW('2nd'!$B$2:$B$100)),1))
This is where i placed the possible search strings.
This is rather complicated :). It's an Array-formula CTRLSHIFTENTER
=INDEX($G$1:$G$4,SMALL(IF(ISNUMBER(SEARCH(INDEX($D$1:$D$4,SMALL(IF(ISNUMBER(SEARCH($D$1:$D$4,SUBSTITUTE(A1," ",""))),ROW($D$1:$D$4)),1)),SUBSTITUTE($F$1:$F$4," ",""))),ROW($F$1:$F$4)),1))
You can create a list with search terms (here in column D) to get right keyword which is searched for in table 2 (columns F:G).

Compare Dates in a column corresponding to Changes in an other row

I have a large sample of medical data I need to try and analyze patterns in Excel worksheet.
I also put them up in a database in MS ACCESS to do my first filters and stuff.
I have the infos of patients, with tests results(POS or NEG), dates of the sample.
I need to be able to check for each patients when the results change from POS to NEG and from NEG to POS
and compare the dates of those two samples.
So far I was doing it manually which isn't viable for my sample.
I was trying to do something in SQL, but that didn't work out for me.
I also am trying to do some VBA or Excel formulas but I admit I'm getting kind of stumped.
I know I should do some for each cell loop or something but I really am lost.
I already grouped each patients info together using sub-totals and stuff.
Your help or at least pointers would be greatly appreciated :D
Here's an example of my data.
enter image description here
Use a formula like this, that in case the name is the same as the row before and the POS/NEG is different from the row before gives you the number of days in between, blank otherwise:
Of course it will give you an error if you try to use it on the 1st line, just enter it in the 2nd line and copy/paste in all the rest.
This should give you the basis for the rest of your analysis.

Separating columns ( array of arrays) - Advanced SQL looping

I tried using a name that more accurately describes my question but msg said I am limited to 150 chars.
Looking for assistance from someone who has advanced SQL skills. Ideally I want to do it in SQL to let the computer do the work. Too much manual manipulation is ripe with the possibility of mistakes.
I've already searched for users groups within Google. All emails are being returned saying the email does not exist anymore.
What I am using appears to be a proprietary version of Dremel SQL / Google SQL, however, someone experienced in Dremel SQL will probably be able to guide me in the right direction.
BACKGROUND INFO:
Pulling a column that is an array column which holds another array (a notes column). I think maybe an array of arrays?
I have not figured a way to do what I am trying to do with Google or Dremel SQL yet.
So for now, I am doing it the hard way.
As originally pulled, the data looks like this [{Array of arrays}, {Array of arrays}, {Array of arrays}, etc., repeat... :
More specifically: [{4 or more text fields which could also hold numbers and separated by commas}, {another set of fields}, {another set of fields}...]
I.E. (this is all in just one column of data and hundreds of rows)
[
{"created":"1540236216969","notes": blah... blah... blah", "original_text_length":534, "User_email":"someone#emailaddress.com","user_shortname":"someone"},
{"created":"1540236216969","notes": blah... blah... blah", "original_text_length":1224, "User_email":"someone#emailaddress.com","user_shortname":"someone"},
{"created":"1540236216969","notes": blah... blah... blah", "original_text_length":1664, "User_email":"someone#emailaddress.com","user_shortname":"someone"}
...
]
The number of these is different for each row pulled and each has a specific ID #
A typical row of data is:
ID #, start_date, end_date, some other fields, notes_(the array field)
WHAT I AM DOING NOW is:
SQL data pull,
exporting to google sheets,
make separate tabs for the different array columns.
copying the notes column (the array column holding arrays) to a separate tab on Google Sheets, then
Split Text To Columns using the first curly brace "{" as the separater.
Here is where my dillema is.
Once pulled, I need to split all of those columns again to separate each of the individual elements in each array. Unable to Split text to Columns again with all of them highlighted. I can Split Text to Columns again one at a time but will really be a pain if I have to do that individually for each column and every row (hundreds of rows). Need to find a way to automate this.
I will also need to change each of unix dates to calendar dates within each array PLUS add rows to the spreadsheet depending on the number of columns from the first split. The columns are different for each row depending on how many notes have been added.
OR... do it with SQL (which appears to be a proprietary type of SQL similar to NoSQL but not the same). I have tried using syntax's for IBM SQL, Oracle SQL, SQL Server, and others found online but none work.
OR... do it with a looping function within Google Sheets.
Possibly re-add it to the database as a new table once both sets of arrays are completely split up.
END RESULT
ID#, date1, date 2, first created date (right now a unix date), first note, first other field, etc...
Then add a new row with
Same ID# from above, date1 from row above, date 2 from row above, next (2nd) created date (right now a unix date), 2nd note, 2nd other field, etc...
Add a new row...
3rd set of notes etc.

Using Excel to to Return unique values for Identical lookup values

I am attempting to use VLookup to match a "Purchase Number" to a specific "Invoice Number". To accomplish this, I have several identifiers about the purchase that I put together to come up with a special "Concat ID". I then have a list of Invoice Numbers that also has the same list of identifiers to create the same "Concat ID'.
The problem I am running into is that the set of identifiers is not unique (aka a purchase of 10 Computers might happen multiple times a year, therefore it is in my list multiple times). Because of this, when I use Vlookup to match the 2 IDs, it always is giving me the same Purchase Number for each time the Concat ID is found (which is just the first occurrence of that Concat ID).
Since there is no other data that would allow for matching (because Invoice date and purchase date are not always the same date or even close to one another), I am just wanting to ensure that each Invoice Number has a unique purchase number.
I'm not sure if its possible, but I was hoping I would be able to perform the vlookup then just skip to the next time the Concat ID is found, allowing for no duplicates, but that hasn't been feasible for me. Because this is a file of 16000 rows, any insight is very appreciated.
I'm sure that's not the clearest explanation, so I've attached a screenshot of the 2 examples in case anyone has any insight. I've been using a simple VLookup, but I'm open to trying VBA or any other suggestions everyone has. As always, thank you Stack community in advance for any help/insight!
Purchase Info
Attempted Matchup with Invoice Info
I'm still not sure what you expect to do with the ConcatID purchase number, but to return the purchase numbers that match your specific ConcatID, generated in the manner you describe in your question, and "skipping to the next" in the case of identical ConcatID's, you can do something like the following;
Note that I made a Table out of your original data, and am using structured references. This allows a much smaller amount of data to be processed compared with referencing the entire column, and will also autoadjust the range as you add/remove rows
Also note that if your Table starts in other than Row 1, you will need to make an adjustment in the formula to account for that.
G2: =INDEX(PurchaseTbl[#All],AGGREGATE(15,6,1/1/(PurchaseTbl[Concat ID]=F2)*ROW(PurchaseTbl),COUNTIF($F$1:F2,F2)),7)
and fill down as far as needed
I've got a really dorky solution, but maybe it will help.
Use this formula to create a unique ID for each row. It will count how many times the specific Concat ID has been used previously in the table, then append it to the end. You can use the Concat ID Unique in your VLookup to get the correct Purchase Number.
=D2 & "_" & (COUNTIF(D$1:D1, "=" & D2))

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: