Auto Date/Time when cell range contains values
I have found a few questions that center around what I'm looking for but I have not been able to figure out how to refactor for my use case.
I am trying to setup a script in GSheet that will enter the current date and time in a specific cell when every cell in the range contains input.
So, e.g. if cells I2 through P2 contain text(any at all), enter the current date and time in cell H2, if not then leave empty. I would then need to apply this to each row (e.g. I3 through P3, and so on).
Is this possible?
google-apps-script google-sheets
add a comment |
I have found a few questions that center around what I'm looking for but I have not been able to figure out how to refactor for my use case.
I am trying to setup a script in GSheet that will enter the current date and time in a specific cell when every cell in the range contains input.
So, e.g. if cells I2 through P2 contain text(any at all), enter the current date and time in cell H2, if not then leave empty. I would then need to apply this to each row (e.g. I3 through P3, and so on).
Is this possible?
google-apps-script google-sheets
add a comment |
I have found a few questions that center around what I'm looking for but I have not been able to figure out how to refactor for my use case.
I am trying to setup a script in GSheet that will enter the current date and time in a specific cell when every cell in the range contains input.
So, e.g. if cells I2 through P2 contain text(any at all), enter the current date and time in cell H2, if not then leave empty. I would then need to apply this to each row (e.g. I3 through P3, and so on).
Is this possible?
google-apps-script google-sheets
I have found a few questions that center around what I'm looking for but I have not been able to figure out how to refactor for my use case.
I am trying to setup a script in GSheet that will enter the current date and time in a specific cell when every cell in the range contains input.
So, e.g. if cells I2 through P2 contain text(any at all), enter the current date and time in cell H2, if not then leave empty. I would then need to apply this to each row (e.g. I3 through P3, and so on).
Is this possible?
google-apps-script google-sheets
google-apps-script google-sheets
asked Nov 26 '18 at 17:02
RichardRichard
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This gives you a good place to start. If you are looking to make adjustments I recommend looking at the SpreadsheetApp documentation. (Namely the getRange method.)
Link to documentation:
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
I did a very basic test and it appears to be working as intended.
function test() {
var date = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(2,9,sheet.getLastRow(),8).getValues();
for (var i = 2; i < range.length +2; i++){
for (var k = 0; k < range[i-2].length; k++){
if (range[i-2][k] !== ""){
sheet.getRange(i, 8, 1, 1).setValue(date);
break
}//END OF IF STATEMENT
}//END OF K LOOP
}//END OF I LOOP
}//END OF FUNCTION
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485846%2fauto-date-time-when-cell-range-contains-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This gives you a good place to start. If you are looking to make adjustments I recommend looking at the SpreadsheetApp documentation. (Namely the getRange method.)
Link to documentation:
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
I did a very basic test and it appears to be working as intended.
function test() {
var date = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(2,9,sheet.getLastRow(),8).getValues();
for (var i = 2; i < range.length +2; i++){
for (var k = 0; k < range[i-2].length; k++){
if (range[i-2][k] !== ""){
sheet.getRange(i, 8, 1, 1).setValue(date);
break
}//END OF IF STATEMENT
}//END OF K LOOP
}//END OF I LOOP
}//END OF FUNCTION
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
add a comment |
This gives you a good place to start. If you are looking to make adjustments I recommend looking at the SpreadsheetApp documentation. (Namely the getRange method.)
Link to documentation:
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
I did a very basic test and it appears to be working as intended.
function test() {
var date = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(2,9,sheet.getLastRow(),8).getValues();
for (var i = 2; i < range.length +2; i++){
for (var k = 0; k < range[i-2].length; k++){
if (range[i-2][k] !== ""){
sheet.getRange(i, 8, 1, 1).setValue(date);
break
}//END OF IF STATEMENT
}//END OF K LOOP
}//END OF I LOOP
}//END OF FUNCTION
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
add a comment |
This gives you a good place to start. If you are looking to make adjustments I recommend looking at the SpreadsheetApp documentation. (Namely the getRange method.)
Link to documentation:
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
I did a very basic test and it appears to be working as intended.
function test() {
var date = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(2,9,sheet.getLastRow(),8).getValues();
for (var i = 2; i < range.length +2; i++){
for (var k = 0; k < range[i-2].length; k++){
if (range[i-2][k] !== ""){
sheet.getRange(i, 8, 1, 1).setValue(date);
break
}//END OF IF STATEMENT
}//END OF K LOOP
}//END OF I LOOP
}//END OF FUNCTION
This gives you a good place to start. If you are looking to make adjustments I recommend looking at the SpreadsheetApp documentation. (Namely the getRange method.)
Link to documentation:
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
I did a very basic test and it appears to be working as intended.
function test() {
var date = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(2,9,sheet.getLastRow(),8).getValues();
for (var i = 2; i < range.length +2; i++){
for (var k = 0; k < range[i-2].length; k++){
if (range[i-2][k] !== ""){
sheet.getRange(i, 8, 1, 1).setValue(date);
break
}//END OF IF STATEMENT
}//END OF K LOOP
}//END OF I LOOP
}//END OF FUNCTION
answered Nov 27 '18 at 10:06
New_2_CodeNew_2_Code
156114
156114
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
add a comment |
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Thanks! I'll give it a try.
– Richard
Dec 2 '18 at 19:26
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
Cool, please consider marking as an answer.
– New_2_Code
Dec 3 '18 at 11:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485846%2fauto-date-time-when-cell-range-contains-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown