Align imported Data with manually added data - google-sheets

Example File: https://docs.google.com/spreadsheets/d/1Ht_2QMGMbHmlxSPoOiLX2vw78IL1wp3VhpOOc66eMqY/edit#gid=0
We are filling Point 1 - 4 manually. The data in A,B,C is sorted through C and will change every now and then. The problem I am noticing now is that A,B,C is moving. But D:G will stay in the same column.
We want to use this file to fill in the data since its our main file. So using the initial =query to also take into account D:G is not an option.
Would there be any other way to "link" D:G to the corresponding values in A:C?

Looking at your sheet I noticed you try a VLOOKUP formula.
Please try the following formula
=INDEX(IFERROR(VLOOKUP(A1:A;Blad1!A2:I;{6\7\8\9};0)))

Of course your approach would cause problems. You're trying to map manual data to some data that is bound to change. You can't expect the manual data to move or change in sync when the imported data changes.
You could probably make it work at least if the imported data does not change in order, and instead gets any new data appended. Even then, it doesn't help you if any of the imported rows gets deleted.
There are only two ways I could see to make this work:
Map your manual data as part of the original sheet where your other data is imported from. In other words, make D:G part of the source of A:C, if possible. This is the best approach. Works even when some imported rows get deleted or changed.
Don't sort A:C at source. Simply append new rows, and import as is. Keep your Blad1 sheet as the local source sheet, and add your manual data to D:G here. Then create a new sheet for sorting or do any other thing you'd like, and use this new sheet to feed your Blad2 sheet. This doesn't work if some of the imported rows get deleted or changed.

Related

CopyAfter() is meant to return the newly created sheet, but doesn't seem to

Update: it turns out it was the SaveToStream() method which saves all sheets instead of the the one, that was the confusing part which lead me to believe the sheet being returned wasn't right
Given the documentation on the CopyAfter() method, the return value is the newly copied sheet
So I wrote the first line of code, now commented out (see below).
The problem is, when I use the sheetWithValues variable from the return of the method, the code below it, does not work (ie The formulas are not replaced with values)
When I comment out the use of the returned value from CopyAfter() and substitute it with workbook.Worksheets[0] as done in the code below, it does work (ie the formulas in the sheet are replaced with values)
Given that experiment, it doesn't seem possible that the return value of CopyAfter() is actually returning the newly created sheet, it's returning something else.
So why does the return value of CopyAfter() not return what is obviously expected here?
I really want to use the return value, because the alternative code below seems brittle and is unlikely to continue working if sheets are re-arranged.
The goal of the code BTW is simply to copy the entire sheet, with values, before exporting... shortly after this code, I take the copied sheet and stream it to PDF.
//var sheetWithValues = workbook.ActiveWorksheet.CopyAfter(workbook.ActiveWorksheet);
workbook.ActiveWorksheet.CopyAfter(workbook.ActiveWorksheet);
var sheetWithValues = workbook.Worksheets[0]; // no idea why this works and the return value does not
sheetWithValues.UsedRange.Value = sheetWithValues.UsedRange.Value
Based on your follow-up comments, it sounds like the problem is with the expectation of IWorksheet.SaveToStream(...), or any of the other IWorksheet.Save*() methods.
These methods will only ever save just the specified IWorksheet when you are saving to a text-based data file format like FileFormat.CSV or UnicodeText (tab-delimited / *.txt). Saving to an Excel file format like FileFormat.OpenXMLWorkbook will result in the entire workbook (so all sheets) being saved, as there simply are too many potential interdependencies on other parts of a workbook to extract and save only one sheet (even if in your case you expect to only have simple values, and not any formulas referring to other sheets, defined names, etc.)
Right now, it looks like you are making a copy of your sheet in the same workbook as the source. In this case you should delete the source sheet prior to saving, which will leave the copied sheet. Do note that if this workbook has any other sheets, those will be persisted as well. You can delete a sheet via the ISheet.Delete() method.
If your source workbook does have a bunch of other sheets that you don't want persisted in your destination workbook, an alternative to copying in the same workbook would be to create a new workbook (Spreadsheet.Factory.GetWorkbook() method) and copy the source sheet into it, after or before the default "Sheet1" worksheet. You'd still need to delete the default "Sheet1" via the ISheet.Delete() method so that only your copied sheet remains.

How do you alphabetize based on dates, and put most recent at the top?

Sample Sheet
How do you reference the Data Import tab and display everything in order of most recent date at the top within the Worksheet, and alphabetize the Vendor Name (column C - Worksheet)?
I have tried the SORT function but little to no luck as it just alphabetized everything in order even when referencing the Import Date from the Data Import.
For visual reference
FIGURE 1:
FIGURE 2: Expected Outcome
To further elaborate:
This one might be tricky, but Column B will be hyperlinks and also needs to be in the correct order that also belongs to its proper data brethren. This is what I currently have and just references everything in order of new data incoming.
(=ARRAYFORMULA(IF('Data Import' !A:A<>"", HYPERLINK("Some_Website" & 'Data Import'!A4:A&, 'Data Import'!A3:A), ""))
This one I'm guessing will not only need to reference the date, but the naming order as well.
Okay. So this was resolved with the query function.
Source info: https://support.google.com/docs/answer/3093343?hl=en
The sample sheet will remain open to those who are in need of knowing how to use it and can view how it was used.
Doing this resulted in the expected outcome. However, there is an issue.
If you have other columns you intend to put manual data entry, this entry data will remain stagnant and will not move.
Only the columns with the query formula will be dynamic and will keep getting pushed downward while your stagnant entries will remain right where they are.
I'm currently looking into Assigned Index Numbers to resolved this.
Solving the Dynamic / Static Data Alignment challenge using Alignment Index Numbers

Google Sheets Filter Function - How can I make data static?

Im trying to make the data that I sort using a filter function stay static in the cells that is is sorted in. I have had this problem a few times and have tried looking it up on Youtube but it seems to be more of an advanced question.
For example when I filter a row of data from one sheet to the next. It is not static data, meaning when I delete the data on the new sheet it stays there until I delete the data on the master sheet.
Please few my example spreadsheet here.
Google Sheets Example Spreadsheet
Any formula (like FILTER) can only process source data. It is linked to the source data permanently. Think of it as a mirror of the source data (and think of changes the formula makes to the source data as a funhouse mirror). You cannot have formula results that you change manually.
If you want a copy of the original data that you can change (and that will no longer be linked to the original data at all), then just select the range containing the original data, Copy it and Paste it to the new location.
If you need some kind of link or updating when the source data changes, or you want the ability to change the source data when you update the copy you made, this requires writing custom scripts. It cannot be done with formulas.

How to automatically copy and paste cells Google Sheets

My goal is to write information in one column, and have it duplicated to another column. Lets say I have my data in cell =A3. I would like this data to automatically be copied into cell =Z50. The only way I know to do this without manually and writing the data or copy and pasting the cells is to go to cell =Z50 and in the function bar set it equal to =A3. I was hoping someone might know of a way to automate this process. By setting the column Z equal to the A column with the same row.
I was looking for the same thing, and even though I haven't tried the ArrayFormula solution, this could be another way to get this automatically copying done:
=QUERY(MySheet!B1:B100,"SELECT *")
Use this formula where you have planned to get the information copied.
"MySheet!B1:B100" = This will be the sheet you want to get data copied from.
"SELECT *" = This will get everything in this interval copied, in case you want any specific data into the interval, you have the option of choosing as well.
I found this tip at: https://productforums.google.com/forum/#!topic/docs/31xTcOHNRJM
This formula might work in cell Z50 (or anywhere else on the sheet that you want the data copied to):
=ArrayFormula(IF(A3:A="",,A3:A))

Link columns so data updates are properly reflected

I have a column with data values and I want to link it to other columns in the same and different sheets but in the same spreadsheet. This is, having the same data in different columns in a spreadsheet while keeping all linked so updates on the source one would affect all of them.
I've tried with:
=SheetName!ColumnIndex:ColumnIndex
(e.g. =Sheet1!A:A) but, although it works, it is a cell reference not a column reference.
What is the best way to achieve it?
Maybe what you want is just the array version of what you have already tried:
=arrayformula(Sheet1!A:A)
(If not, please clarify!)

Resources