my company has switched to managing lead generation in Google Sheets, and we're trying to make the in-Sheets process more efficient. Here's an example sheet: https://docs.google.com/spreadsheets/d/1MrJiHDd7MUXp9eWspMR8gqjA_fBIv9w5vfos3oJqDxI/edit?usp=sharing.
The goal is a script that can be run from a menu that does the following:
- Copy data from Data
- Paste values only in Destination in the row after the last with data
- Clear Data dataset (there are some formulas in Data that use a third-party API that I only want to run once)
- In Destination, combine rows to remove duplicates, but keeping unique values using "," as a delimiter
Re: 4, here's an example:
amomsvillage.com A Mom's Village Frank [email protected] [email protected]
amomsvillage.com A Mom's Village Gary [email protected] [email protected]
Becomes:
amomsvillage.com A Mom's Village Frank,Gary [email protected] [email protected],[email protected]
Below is the formula I'm using for 1-3, which mostly works (only issue is that it's not getting the actual last row of data, i.e., where A starts having blanks). However, I'm having to separately run PowerTools' Combine Rows to accomplish 4, when it'd be great to do in one step. [Goal] shows how the data should look after 1-4.
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Functions')
.addItem('Copy Paste', 'moveValuesOnly')
.addToUi();
}
function moveValuesOnly() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange('Data!A2:E');
var destSheet = ss.getSheetByName("Destination");
var lastRow = destSheet.getLastRow();
destSheet.insertRowAfter(lastRow);
source.copyTo(destSheet.getRange(lastRow + 1,1),{contentsOnly: true});
source.clear();
}
There are some additional improvements I'd like to make, but I want to get the above first!