chrono2483
Board Regular
- Joined
- Aug 23, 2014
- Messages
- 164
- Office Version
- 2016
Hello,
I was able to search and find to codes that independently was able to get to work/accomplish what I want it to do. However when I try to include them in the same sheet, it looks like code#2 cancels out the first one. Is there a way to combine the two so they both work?
Code 1: Adjusted the drop-down list based on user selection in Col B, C and D
Code 2: Date Stamps and edits on that row
Code 1:
Code 2:
Can anyone point in the right direction or help explain/understand how to merge the two together?
Thank you.
I was able to search and find to codes that independently was able to get to work/accomplish what I want it to do. However when I try to include them in the same sheet, it looks like code#2 cancels out the first one. Is there a way to combine the two so they both work?
Code 1: Adjusted the drop-down list based on user selection in Col B, C and D
Code 2: Date Stamps and edits on that row
Code 1:
HTML:
function depDrop_(range, sourceRange){
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange, true).build();
range.setDataValidation(rule);
}
function onEdit (){
var aCell = SpreadsheetApp.getActiveSheet().getActiveCell();
var aColumn = aCell.getColumn();
if (aColumn == 2 && SpreadsheetApp.getActiveSheet()){
var range = SpreadsheetApp.getActiveSheet().getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
depDrop_(range, sourceRange);
}
else if (aColumn == 3 && SpreadsheetApp.getActiveSheet()){
var range = SpreadsheetApp.getActiveSheet().getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
depDrop_(range, sourceRange);
}
else if (aColumn == 4 && SpreadsheetApp.getActiveSheet()){
var range = SpreadsheetApp.getActiveSheet().getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
depDrop_(range, sourceRange);
}
}
Code 2:
HTML:
function onEdit(event) { var eventRange = event.range; if (eventRange.getColumn() == 4) { // 4 == column D // getRange(row, column, numRows, numColumns) var columnXRange = SpreadsheetApp.getActiveSheet().getRange(eventRange.getRow(), 57, eventRange.getNumRows(), 57); var values = columnXRange.getValues(); for (var i = 0; i < values.length; i++) { if(!values[i][0]){ // If cell isn't empty values[i][0] = new Date(); } } columnXRange.setValues(values); }}
Can anyone point in the right direction or help explain/understand how to merge the two together?
Thank you.