Zoho Sheet · Automation and productivity · Intermediate
Add a button to run a trusted macro or custom function
Insert a clearly labelled button, assign one inspected macro, and test its target range before allowing other people to click it.
Quick answer
Insert a clearly labelled button, assign one inspected macro, and test its target range before allowing other people to click it.
Before you start
Zoho Sheet web editor in an English desktop browser; rolling service, official documentation reviewed 20 October 2026. Not desktop-app or mobile instructions. Use an editable practice file containing only synthetic data. Keep the original unchanged and record the file name and storage location so that you reopen the same copy. These are documentation-based instructions and independently checked examples, not a claim of native application testing.
Choose a harmless existing action
Use a private workbook with a trusted macro named FormatPracticeHeader that formats only Sheet1!A1:C1. First record, inspect and run that macro directly in the practice file. If it sends messages, fetches data, deletes rows or performs another consequential action, it is not the macro for this exercise.
Enter headers Item, Units and Status in A1:C1, with Blue / 12 / Ready and Green / 8 / Review beneath them. Leave E2:H5 available for the button. Before proceeding, note the header’s initial formatting and confirm the data values are unchanged.
A button is an easier way to trigger code, not a sandbox or a permission system. Its label must explain the action a reader is about to run.
Insert and assign the button
- Choose Insert → Button.
- Name the object
Format practice header. If you need to change the name later, use the button’s top-right … → Edit Label action. - Open … → Assign Existing Macro.
- Select FormatPracticeHeader from the list and choose Assign. Check the name carefully if several similar macros exist.
- Position the button in the empty area so it does not cover the source data or a calculation.
The same menu provides routes for a new macro and for existing or new custom functions. Do not select those merely because the intended macro is absent. First confirm you are in the correct workbook and that the macro was saved.
Test the button’s real effect
Restore A1:C1 to the macro’s expected initial state, such as unbolded text. Click the button once. Verify that the header changes as intended and that the Blue and Green records remain intact. Select a distant cell and repeat the test from the same known starting state. A fixed-range macro must not wander to that active cell.
A recorded macro may toggle formatting rather than set it. If a second click removes bold, document that behavior and improve the underlying macro before calling the button a reliable Format action. The visual appearance of a button gives no information about whether its code is repeatable.
For an independent check, sum the two units values outside the table. It must remain 20 before and after activation. If a wrong range changes, stop using the button and inspect its assignment rather than clicking repeatedly.
Maintain the assignment carefully
If you clone the button using … → Clone, Zoho documents that the replica keeps the same name and functionality. Rename it only if its label remains truthful; a different label does not change the assigned code. Avoid leaving multiple indistinguishable triggers in a report.
Deleting is especially important: Zoho’s button article warns that deleting a button also deletes the assigned macro function. Do not treat the button’s Delete action as harmless cosmetic cleanup. Preserve and inspect the macro first, check other dependencies, and use a disposable copy for any deletion test.
Hand off an understandable control
Place a visible explanation near the button: Changes only Sheet1 A1:C1; no external actions. Keep that statement aligned with the actual code. If the macro is later expanded, revise both the explanation and its authorization before distributing the workbook.
Reopen the saved workbook and verify the label and assignment before using it. A PDF or screenshot may show a button but cannot prove executable behavior; an exported workbook needs its own compatibility test. Retain the editable Zoho master and the macro’s documented scope.
Related tutorial
Continue with cell formatting basics.
Official sources
Documentation reviewed 20 October 2026.