In Office Scripts, there isn't a direct equivalent to the VBA Target.Calculate syntax that allows you to highlight an entire row automatically on mouse click without additional key presses. However, you can achieve the desired functionality by using the getRange method to select the entire row based on the active cell's position. Here’s a simple example of how you can highlight the entire row of the active cell:
function main(workbook: ExcelScript.Workbook) {
// Get the active cell's range
let activeCell = workbook.getActiveCell();
// Get the entire row of the active cell
let entireRow = activeCell.getEntireRow();
// Clear previous highlights
workbook.getActiveWorksheet().getRange("1:1048576").getFormat().getFill().clear();
// Highlight the entire row
entireRow.getFormat().getFill().setColor("#00FFFF"); // Set your desired highlight color
}
This script retrieves the active cell, gets its entire row, clears any previous highlights, and then applies a new highlight color to that row. You can run this script whenever you want to highlight the row of the active cell without needing to press the DELETE key.
References: