{"id":"code-work-office-vba-hide-done-rows","audience":"office","category":"coding","track":"coding","technique":"constraints","title":"Write a tight VBA macro that hides finished tasks","free":false,"task":"You want a VBA macro named HideDoneRows that hides every row on the sheet named Tasks whose Status in column F is done, starting at row 2 and stopping at the last row with data in column A (the list grows weekly). Status is typed inconsistently, so done must match any capitalization and stray spaces. No message boxes and no On Error lines. One code block of at most 12 lines, then under 25 words outside the code.","materialLabel":"Tasks sheet preview (attached to your prompt automatically)","material":"TASKS sheet - team tracker (row 1 is headers)\nA Task | B Owner | C Due | D Priority | E Notes | F Status\nOrder toner | Ana | 11/03 | Low | brand: Kopa | Done\nBook room for offsite | Raj | 11/05 | High | Atrium? | In progress\nRenew parking passes | Lou | 11/07 | Med |  | done\nUpdate phone list | Mei | 11/08 | Low | after new hires | DONE \nFix badge printer | Raj | 11/10 | High | vendor called | Waiting\nPlan holiday lunch | Ana | 12/01 | Med | budget $400 | Not started\n\nNotes:\n- About 60 rows today; new tasks are added at the bottom every Monday.\n- The workbook also has sheets named Archive and Lookups.\n- People run macros from the Developer tab while a different sheet is often open.\n- Column E notes are sometimes long and wrap.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":12},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not naming the sheet","why":"The AI uses ActiveSheet, so running it from another tab hides the wrong rows.","fix":"Add: \"Work on the sheet named Tasks, not the active sheet.\"","checks":["r0"]},{"title":"Leaving the range open","why":"The AI loops to a fixed row like 1000 or starts at row 1 and hides the header.","fix":"Add: \"Start at row 2, stop at the last row with data in column A.\"","checks":["r1"]},{"title":"Not mentioning messy statuses","why":"The AI checks for exactly \"Done\" and misses \"done\" and \"DONE \".","fix":"Add: \"Match done in any capitalization, ignoring spaces. No MsgBox or On Error.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the macro, so you're left to pick and test them yourself.","fix":"Add: \"Give one macro only, in one code block, no alternatives.\"","checks":["codeBlocks","maxCodeLines"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 15 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Names the macro and the sheet","patterns":["hidedonerows","tasks","sheet name"]},{"label":"Sets the row range","patterns":["row 2","last row","header"]},{"label":"Covers messy capitalization","patterns":["capital","case","trim","spaces","ucase|lcase"]},{"label":"Rules out extras","patterns":["msgbox","message box","on error","no extras"]},{"label":"Caps the code length","patterns":["\\d+\\s*lines","at most","under \\d+","short"]}],"hint":"The AI will write a generic macro for whatever sheet is open. Name the sheet and the rows, and tell it how messy the Status column is.","rubricLabels":["Is a Sub named HideDoneRows that works on Worksheets(\"Tasks\") (or Sheets(\"Tasks\")) by name, not ActiveSheet","Loops from row 2 to the last used row found from column A (such as Cells(Rows.Count, \"A\").End(xlUp).Row), not a fixed number like 1000","Compares column F using Trim with UCase or LCase (so \"Done\", \"done\" and \"DONE \" all match) and hides with EntireRow.Hidden = True, with no MsgBox or On Error lines"]}