Updating Array1 with Array2 using Google Apps Script
This is a sample script for updating Array1 with Array2 using Google Apps Script.
As a sample situation, there are 2 arrays (Array1 and Array2) of the 2-dimensional array. The sample situation can be seen in the above sample Spreadsheet.
- Conditions
- When the values of column “A” of Array2 are existing in column “A” of Array1, the rows of Array1 are updated by that of Array2.
- When the values of column “A” of Array2 are not existing in column “A” of Array1, the rows of Array2 are appended to Array1.
- When the values of column “A” of Array1 are not existing in column “A” of Array2, the rows of Array1 are deleted.
I sometimes see such questions on Stackoverflow. So, I thought that when this sample script is posted, it might be useful for users.