This set of code will add a note to a cell showing the date of the change and the old text before the change!
function onEdit(e) {
const { range, oldValue } = e;
const note = `Cell edited on ${new Date()}. Previous value: ${oldValue}`;
range.setNote(note);
}
Highlight and copy the code above
Go to Extensions/Apps script
Highlight the text in the code editor
Paste the code you copied to the clipboard
Save and name the project
Go to your sheet and edit a cell
What happens?
This script (attached to the form) will allow you to have students fill out a form, and when they submit the form, a new slide with their response will be added to the slide presentation.
Create a Form with two items, Name and Response
Add one slide that has a Text box titled "Name" and one titled "Response" Format and organize them however you want. I also hide this slide from showing.
On the form, open the script editor (under the 3 dots to the right of Send)
Paste in this script and be sure to put in your Presentation ID and the slide template ID you are using for the responses.
Save and name the script
You will have to add a trigger to this script and set it to execute on form submit.
Distribute the form with a QR code or however you like.
Collect the audience responses to the slide presentation.
function audienceResponse(e) {
const openPresentation = SlidesApp.openById('place your slide presentation ID here');
const audienceSlide = openPresentation.getSlideById('place your slide ID here')
const newSlide = audienceSlide.duplicate();
const newSlideId = newSlide.getObjectId();
var items = e.response.getItemResponses();
const changeSlide = openPresentation.getSlideById(newSlideId);
changeSlide.replaceAllText('Name', items[0].getResponse());
changeSlide.replaceAllText('Answer', items[1].getResponse());
}
function sheet1ToSheet2(){
const ss = SpreadsheetApp.getActiveSpreadsheet();
const source = ss.getSheetByName('Sheet1').getRange('A1:J20').getValues();
//console.log(source);
const destination = ss.getSheetByName('Sheet2');
const date = new(Date);
destination.getRange(destination.getLastRow()+1,1,1,1).setValue(date);
destination.getRange(destination.getLastRow()+1,1,20,10).setValues(source);
}
I asked ChatGPT this question:
I need a google apps script to copy the data on Sheet1 to Sheet2 and i need it to have a Utility menu in order to run.
And I got this response
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Utility')
.addItem('Copy Sheet1 to Sheet2', 'copySheet1ToSheet2')
.addToUi();
}
function copySheet1ToSheet2() {
var sheet1 = SpreadsheetApp.getActive().getSheetByName('Sheet1');
var sheet2 = SpreadsheetApp.getActive().getSheetByName('Sheet2');
var data = sheet1.getDataRange().getValues();
sheet2.clearContents();
sheet2.getRange(1, 1, data.length, data[0].length).setValues(data);
}
Followed by these instructions:
To use this script, follow these steps:
Open your Google Sheets document.
Click on the "Tools" menu at the top of the screen.
Select "Script editor" from the dropdown menu.
Copy and paste the above code into the script editor.
Save the script.
Go back to your Google Sheets document.
Refresh the page (or close and reopen the document).
You should now see a "Utility" menu at the top of the screen.
Click on "Utility" and select "Copy Sheet1 to Sheet2" to run the script.
Note: Make sure that you have both a Sheet1 and Sheet2 in your document with the data you want to copy. Also, the script will clear the contents of Sheet2 before copying the data from Sheet1. If you want to keep any existing data in Sheet2, you'll need to modify the script to append the data instead of overwriting it.