Many people are asking why I want to do this. I want to do this so that when I do my mail merge (this sends students their overdue book lists from the library), I don't send a student an email more than once. I never use this data more than once, I only use it to send a quick message, I never manipulate or work with the data so I don't care if it's hard to work with! I hope this makes sense! Thank you for your feedback thus far.
Google Sheet starts like this:
I want it to look like this:
I have started some script, which I am sure you will all laugh at (I know very little of programming). However, It'd be awesome to be able to do this. Basically, combine the rows that have an identical entry in column 1, by putting the values for the columns for those rows together into one row. The numbers can be added, and the data separated by a comma or a line break.
This is what I have so far....
function myFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getActiveSheet(); var last = sheet.getLastRow(); //find identical entries in column 1// for(i in data){ var row = data[i]; var duplicate = false; for(j in newData){ if(row.join() == newData[j].join()){ duplicate = true; } } if(!duplicate){ newData.push(row); } } //add information from rows of identical entries into one row using a comma// //delete empty rows// }
It's a bit of a kluge but it runs with my fake data. Hopefully you can get it running with yours. It usually takes me some tweaking to get something like this a little more streamlined. I have a few comments in there to explain some of the key items.
There actually are many reasons why one would want to combine similar rows.
I for one, have a form that allows users to fill out information about properties. New info comes in everyday, so the forms will be reused for new entries.
All properties have a unique identifier, but the first form entry is useful to give the owner's name and address, along with other information.
The next form entry does not need to populate, (and re-type) all that info, but it does need to add other new details to the first entry.
Lastly, I want to report based on unique entries, with other info combined to read with the property.
Part of the answer for me is a custom function created by Hyde, called JoinRows.
Search for that.
Good luck!