Last active
June 29, 2017 22:56
-
-
Save Narvey/8d4c6239725c094059d106b75e6a23d0 to your computer and use it in GitHub Desktop.
Deletes lines that have certain text in cell B - Shared with Script Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete certain lines | |
description: Deletes empty lines and lines that have certain text in cell B representing a row that is not in use | |
author: Narvey | |
host: EXCEL | |
api_set: {} | |
script: | |
content: "$(\"#run\").click(run);\r\n\r\nasync function run()\r\n{\r\n try\r\n {\r\n await Excel.run(async (ctx) =>\r\n {\r\n var deleteVal = document.getElementById(\"delete\").value.toLocaleLowerCase()\r\n var rows = ctx.workbook.worksheets.getActiveWorksheet().getUsedRange().load(\"values\")\r\n await ctx.sync()\r\n var rowNum = 0, used = 0, v = \"\"\r\n for (rowNum = rows.values.length-1; rowNum >= 0; rowNum--)\r\n {\r\n v = rows.values[rowNum][1]\r\n if (v == null || v.length == 0 || v.toLocaleLowerCase() == deleteVal)\r\n {\r\n rows.getRow(rowNum).delete(\"Up\")\r\n await ctx.sync()\r\n }\r\n }\r\n await ctx.sync()\r\n })\r\n }\r\n catch (error)\r\n {\r\n OfficeHelpers.UI.notify(error)\r\n OfficeHelpers.Utilities.log(error)\r\n }\r\n}\r\n" | |
language: typescript | |
template: | |
content: "<br><br><!--spacing for message boxes-->\r\n<button id=\"run\" class=\"ms-Button\">\r\n <span class=\"ms-Button-label\">Run</span>\r\n</button>\r\n<br>\r\n<label>Text to consider empty row:</label>\r\n<input type=\"text\" id=\"delete\" class=\"ms-Text\" value=\"Not in use\" />\r\n<br>\r\n\r\n" | |
language: html | |
style: | |
content: "/* Your style goes here */\r\n" | |
language: css | |
libraries: | | |
# Office.js | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
# CSS Libraries | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
# NPM libraries | |
[email protected]/client/core.min.js | |
@microsoft/[email protected]/dist/office.helpers.min.js | |
[email protected] | |
# IntelliSense: @types/library or node_modules paths or URL to d.ts files | |
@types/office-js | |
@types/core-js | |
@microsoft/[email protected]/dist/office.helpers.d.ts | |
@types/jquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment