Get Started
Documentation
Macros
More information
|
Writing your own macrosNow that you know how macros work, let us try and write your own macro. Say, we have a table and need to color the alternate table rows (odd will be colored green, even will become red). The table contains 200 rows (would take quite some time to do that manually) and columns from A to S.
Now let's sum it up with the complete script code: (function() { var oWorksheet = Api.GetActiveSheet(); for (var i = 1; i < 200; i += 2) { var rowOdd = i, rowEven = i + 1; oWorksheet.GetRange("A" + rowOdd + ":S" + rowOdd).SetFillColor(Api.CreateColorFromRGB(118, 190, 39)); oWorksheet.GetRange("A" + rowEven + ":S" + rowEven).SetFillColor(Api.CreateColorFromRGB(186, 56, 46)); } })(); Paste the code above to the macros window and click Run. The table rows from 1 to 200 will be colored alternately in less than a second. |
© Ascensio System SIA 2021. All rights reserved
|