var sheetName = "Sheet1"
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var rng = e.range;
var row = rng.getRow();
var col = rng.getColumn();
var timeStamp = ss.getRange(row,col-1).getValue();
var rowHeader = ss.getRange(3,col).getValue();
if(!rng.isBlank() && timeStamp == "" && rowHeader == "COMPLETED" && row > 3){
ss.getRange(row, col-1).setValue(new Date());
}
}
this code for Workbook_Open
Private Sub Workbook_Open()
Call testTime
End Sub
this code for Module
Sub macro_timer()
'Tells Excel when to next run the macro.
Application.OnTime Now + TimeValue("00:00:01"), "testTime"
End Sub
Sub testTime()
Dim datntime As String
Dim timee() As String
datntime = Now
timee = Split(datntime, " ")
If timee(1) > "10:00:00" And timee(1) < "11:00:00" Then
Application.ActiveWorkbook.Activate
Else
MsgBox ("you can edit this sheet only from 10 am to 11 am.")
Application.ActiveWorkbook.Save
Application.Quit
End If
Call macro_timer
End Sub
Note: First select all cells then click right and select "Format cells" option then go to protaction Tab then uncheck locked option and press ok button and after that past below code in the sheet code window. Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password = "ok" Target.Cells.Locked = True ActiveSheet.Protect Password = "ok" End Sub
<script>
var table = '<table><tr><td>Second</td></tr></table>';
var uri = 'data:application/vnd.ms-excel,' + encodeURIComponent(table);
var filename = "Report_" + new Date().toISOString().slice(0,10) + ".xls";
var a = document.createElement("a");
a.href = uri;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
</script>