Hi jerry,
To set the RowCounter01 variable to the value in RDate, cell J1 using Microsoft Office Script in Excel, you can use the following code:
// Get the value from cell J1 in the RDate sheet
let sheetName = "RDate";
let cellAddress = "J1";
let value = context.workbook.worksheets.getItem(sheetName).getRange(cellAddress).values[0][0];
// Set the RowCounter01 variable to the retrieved value
let RowCounter01 = value;
In the above code-
- The 'sheetName' variable is set to the name of the sheet you want to retrieve the value from.
- The 'cellAddress' variable is set to the cell address of the cell you want to retrieve the value from.
- The 'context.workbook.worksheets.getItem(sheetName)' function is used to get the specified sheet from the workbook.
- The 'getRange(cellAddress)' function is used to get the range of the specified cell.
- The 'values[0][0]' property is used to retrieve the value of the cell as a JavaScript array.
- And, the retrieved value is assigned to the 'RowCounter01' variable.
Note- Make sure to add the necessary Microsoft Office Script APIs and authentication code to your script before running this code.
Best Regards.