Sheet.js how does encode_col and decode_col work? - sheetjs

How does decode_col, and encode_col, know which sheet to target if you never pass one in?
encode_col / decode_col converts between 0-indexed columns and column names.
If I give it a column name, like "foobar" and that column exists in different sheets, or wholly different files I'm processing how will these two functions know where that column is?

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

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

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!

Multiple substitue or replace text in excel using a table

I'd like to create a super substitute function in excel (if there is such a thing). For my needs, nesting is insufficient because my substitution list is long.
What I'd like to do is have a named table with two columns for the function to use as a look-up for potential substitutions. The first column would contain the original text and the second would contain the replacement text.
If we look at the above example, the columns R and S consists of my table, with column R as the original text that I wanted replaced with the equivalent row entry in column S, if found in my list. My data in column V is the list that I want to work on. I want the formula in column W to look at the equivalent entry in column V and lookup in the table for any matches within the text. If there is a match, then I want that text from column R replaced with the text in column S. In some cases there can be 2 matches, as with the top example of 'LHR:JFK' which should ideally get replaced to 'LON:NYC'.
There are ways to do this with VBA but I would like to know if there is an Excel formula option for the same as I don't know where to begin with VBA.
Your help is greatly appreciated.
Thanks,
Neha
This will do as you ask:
=SUBSTITUTE(SUBSTITUTE(V2,LEFT(V2,3),IFERROR(VLOOKUP(LEFT(V2,3),R:S,2,FALSE),LEFT(V2,3))),RIGHT(SUBSTITUTE(V2,LEFT(V2,3),IFERROR(VLOOKUP(LEFT(V2,3),R:S,2,FALSE),LEFT(V2,3))),3),IFERROR(VLOOKUP(RIGHT(SUBSTITUTE(V2,LEFT(V2,3),IFERROR(VLOOKUP(LEFT(V2,3),R:S,2,FALSE),LEFT(V2,3))),3),R:S,2,FALSE),RIGHT(SUBSTITUTE(V2,LEFT(V2,3),IFERROR(VLOOKUP(LEFT(V2,3),R:S,2,FALSE),LEFT(V2,3))),3)))

VBA: copying excel columns: best practice for storing cell references?

I have a big file with data, updated weekly, from which a VBA script copies a lot of columns of various lengths and starting points, and then pastes these columns one by one into another file.
My question is how to best store the cell references that the script needs to be able to copy the correct columns? Currently there is a bunch of arrays storing the starting row number, starting column number, sheet number etc which are all indexed the same, and a loop function which does the actual copy paste work.
This (exceptionally bad?) solution would obviously be an absolute nightmare if the source file would change slightly at some point. So how should one do it better?
Excel is using enumerations for this purpose. Enums are the most efficient way to assign names to constants.
[Private] Enum WeeklyReport
FirstRow = 3
StartColumn = 1 ' Columns:
Text
Values
Totals = 17
Remarks
End Enum
The above declaration specifies the enum WeeklyReport with 5 values, one row and 4 columns. Text has the value of 2 because if the value is omitted the previous is incremented by 1. Therefore, Remarks = 18.
You can call up the values by their full name, like, WeeklyReport.Remarks or by their short name, like Remarks. That's why Excel gives unique names to its enumerations, like xlUp, which you might be using all the time without even knowing the enumeration's name. The names given above are possible but not very good.
Enumerations are a data type of their own which is interchangeable with Long. Declared before any code, at the top of a code sheet, they are available throughout that sheet if Private, otherwise throughout the project.

Need a simple search function to display most common value in a column. (with ambiguous choices)

I have a very large array of data with many columns that display different outputs for the values presented. I would like to add a row above the data that will display the most common occurring value or word below.
Generally I would like to have each top of the column (right under the column label in row 1) have the most common value below. I will then use this value for various data analysis functions!
Is this possible, and if so, how? Preferably this will not require VBA, but simply a short code in the cell.
One caveat: The exact values may vary, so there is no set list where I can say "it will be one of these."
Any ideas appreciated!
Try a series of =COUNTIF(A:A,"VALUE TO SEARCH") functions if you want to stay away from VBA.
Otherwise, the best method would be to iterate through each column via VBA. With this method, you can even count the "varying" values and return the count and/or the value itself.
http://www.excel-easy.com/examples/most-frequently-occurring-word.html
This is a single formula you would write at the top of each column. Does not require VBA. You can replace the set range to an entire column, such as (A:A) instead of (A1:A7).
If you mean an array as in a data type, it could work differently but it depends what you're trying to do.
With data from A3 through A16, in A2 enter:
=INDEX($A$3:$A$16,MODE(MATCH($A$3:$A$16,$A$3:$A$16,0)))
This will work for text as well as numbers. Adjust this to match the column size.