Office Scripts Optimization

shaunreeder

New Member
Joined
Aug 10, 2022
Messages
3
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hello all,

I have a script I made in Excel Web to automate a task when adding data to the spreadsheet.

It works fine and has no issues but it's a little bit of a delay from when the user clicks the button and the data populates on the sheet.

Any ideas on how can I help speed up the script while keeping the same functionality?

JSON:
function main(workbook: ExcelScript.Workbook) {

    //disable auto calculation mode
    workbook.getApplication().setCalculationMode(ExcelScript.CalculationMode.manual);

    //Gets the current work sheet
    let currentWorksheet = workbook.getActiveWorksheet();
    //Gets Last row of used range
        let usedRange = currentWorksheet.getUsedRange(true).getLastRow().getRowIndex();
    //Gets Selected Provider
        var setprovider = currentWorksheet.getRange('D1').getValue()
        var week = currentWorksheet.getRange('B1').getValue()
  //Gets Next Rows Range
      const nextrow = currentWorksheet.getRangeByIndexes(usedRange+1,0,9,5);
 //Adds The new rows to bottom of the table
  nextrow.setValues([
    //Weekly Metrics
    ["Weekly", week, setprovider, , "AtlantiCare First"],
    ["Weekly", week, setprovider, , "Weekly Visits"],  
    ["Weekly", week, setprovider, , "Missing Charges"],

    //Monthly Metrics
    ["Monthly", week, setprovider, , "Time To Be Seen Access %"],
    ["Monthly", week, setprovider, , "No Show Rate"],
    ["Monthly", week, setprovider, , "Panel Size"],
    ["Monthly", week, setprovider, , "Rate The Provider Score"],
    ["Monthly", week, setprovider, , "RVU Production"],
    ["Monthly", week, setprovider, , "Wellness Visit % Completion"],
  ]);
//Copys a new Provider Data Validation List
      const getpdv = workbook.getWorksheet('Data Validation').getRange('C1');
      const setproviderselection = currentWorksheet.getRange('D1').copyFrom(getpdv);
//Copys a new Weekly Data Validation List
      const getwdv = workbook.getWorksheet('Reporting Weeks').getRange('M3');
      const setweeklyselection = currentWorksheet.getRange('B1').copyFrom(getwdv);
nextrow.getUsedRange().select()

  //turn it back on
  workbook.getApplication().setCalculationMode(ExcelScript.CalculationMode.automatic);

}
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top