•1 min read•from Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community
Office Scripts - Delete rows that contain certain text
function main(workbook: ExcelScript.Workbook) { // Get the used range on the current sheet. const currentSheet = workbook.getActiveWorksheet(); // Get the RangeAreas object for each cell with a formula. const usedRange = currentSheet.getUsedRange(); //get the values of the range let values = usedRange.getValues(); //get the row count of the range let rowCount = usedRange.getRowCount(); // Column A is 0, B is 1, C is 2 etc. // starting at the last row, check if the cell in column 'B' equals to 'ZEBRA'. If it is, then delete the entire row. for (let i = rowCount - 1; i >= 0; i--) { if ( values[i][1] == "Extended Systems") { usedRange.getCell(i, 1).getEntireRow().delete(ExcelScript.DeleteShiftDirection.up) } } } Good morning all, I have a workbook, no tables. In column C I have a bunch of zoo animals. I want to delete Zebra out of there. My script is not working, can another set of eyes see why?
[link] [comments]
Want to read more?
Check out the full article on the original site
Tagged with
#row zero
#Excel alternatives for data analysis
#natural language processing for spreadsheets
#generative AI for data analysis
#rows.com
#AI formula generation techniques
#Excel compatibility
#financial modeling with spreadsheets
#no-code spreadsheet solutions
#formula generator
#Excel alternatives
#Office Scripts
#ExcelScript
#workbook
#usedRange
#delete
#ExcelScript.DeleteShiftDirection
#currentSheet
#getValues
#script