Reputation: 21
Could Someone please help me with the fallowing question?
I set up a Spreadsheet that will relate to the question below https://docs.google.com/spreadsheets/d/1sp8j2zNzzr-lnkMPnYt_aukKM7vqf_31Tq71De_xr04/edit?usp=sharing
(Im not sure the fallowing is possible. Please Advise)
I want to set up a day timer that continues to count the days as soon as any data is entered into the row and for it to stop when I type a word like "X" or even better checkmark in a checkbox. Once I Check mark or type the word, I want the entire row to Greyout/Blackout (highlight with Black)
I am trying to set this sheet up for work and I will truly appreciate any help.
To give more detail, I built a form through google that I will use to jot down who called me, why they called me and if it is an High Priority call or a low priority call, if they require service to there machines etc... Basically this form creates a spreadsheet, I want to be able to complete the task from that call and checkmark it or "something" that will blackout the row letting me know I have completed the task, If however I have not, than I want a timer telling me how long its been since I took that call, 3hrs, 4 days, 10 days, etc... Hope that makes more sense
Thank you
Sunny Rai
Upvotes: 1
Views: 286
Reputation: 12671
You can use a simple spreadsheet formula to calculate the number of days difference between the timestamp column and today:
=DATEDIF(A2, NOW(), "D")
There is no built-in way to have this formula automatically added to each new submission, but you can use the copyDown add-on to achieve that.
Upvotes: 0
Reputation: 1522
What you're describing is totally possible!
Step by step, here's what you'll want to do...
daily()
.dataRange
formValues
formColors
1
daily()
every dayBut what does this all look like? Glad you asked! The function looks like this:
function daily() {
var dataRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1').getDataRange();
var formValues = dataRange.getValues();
var formColors = dataRange.getBackgrounds();
for (var i = 1; i < formValues.length; i++) { // Start on i=1 to skip the header row
var dayCount = formValues[i][10]; // The current day count is on column 11, which is index 10 because we zero-index
if (dayCount == '') { // If dayCount isn't set...
dayCount = 1;
} else { // Otherwise, if it is...
dayCount = dayCount + 1;
}
formValues[i][10] = dayCount; // Update the original grid of values
if (dayCount >= 10) { // If the dayCount is 10...
for (var j = 0; j < formColors[i].length; j++) { // Loop over the width of the form colors
formColors[i][j] = '#000000'; //Change whatever background color was there to black
} //end for j
} //end if dayCount>=10
} //end for i
/* At this point, formValues and formColors contain what should be in the sheet for this row */
dataRange.setValues(formValues).setBackgrounds(formColors); // Update the range with our new values
}
Remember also that you must make a trigger in Resources > Current Project's Triggers
. Set yourself up a trigger to run daily
as a time-driven
event, configured as a Day timer
for whenever you won't be working. Then you're done!
Upvotes: 1