I am trying to save a script to apply a number format to whatever cells I have selected on the worksheet. Recording the script is easy, but it only applies to whatever cell I am in at the time. However, I could be in a different cell or I may need to apply the format to a range of cells.
This is a copy of my script at the moment but it is only being applied to cell E8, whereas I want it to run on whatever cells I have selected at the time.
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
Set format for range E8 on selectedSheet
selectedSheet.getRange(“E8”).setNumberFormatLocal(“#,##0;(#,##0);-“);
}
Thank you for your help.
I am not sure what I need to replace E8 with to get it to apply to other cells.
Emma Emerson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.