What is Office script? Office Scripts in Excel let you automate your day-to-day tasks. Office Scripts are written in TypeScript, which is a superset of JavaScript. If you're familiar with JavaScript, your knowledge will carry over because much of the code is the same in both languages.
Exercise - creating your 1st office script.
Deadline :
We are going to modify the code in order to meet our object. We are going to create a list of people's information and put it in a data sheet. The information is encoded on the dashboard. When a button is clicked, the information is transferred to the data sheet, and the field on the dashboard is cleared.
let begin
expected result:
our first code is let dashboard=workbook.getWorksheet("Dashboard")
where : let is a command letting the variable dashboard store object. workbook is an object. getWorksheet is a property of an object workbook. Dashboard is a name of sheet in our Excell worksheet.
the line of code simply telling the computer to use Dashboard sheet and store it temporarily in dashboard variable. therefore, you can replace the word Dashboard with the name of the sheet that you are using. and you can also change the dashboard in any word you like.
note: the color red words are the code Lets continue our coding ...
var is a command the tell the computer to prepare a space on the computer memory for future use. it followed by a variable name, in our example, Name1 used to name the space in the memory of the computer. After the variable name it is followed by = sign, it assigns a value to the variable, or it just put a value to the space in the computer memory. therefore, the code var name1 = dashboard.getRange("c3").getValue() , it getting any value that is encoded to the cell C3 of the Dashboard sheet and put it on the variable name1.
lets transfer the data to data sheets.
the code datasheet.getRange("A2").setvalue(Name1) this code get the value of the variable Name1 ang put it in cell A2 in data sheets
Add the script on the Dashboard Sheets
if you code it correctly the Nes will be automatically put in Data sheet Cell A2
Activity Complete the code so that the Entry on the cell C3 or the name, C4 for the Address and C5 for the birth day is transfer to Data sheet