Skip to content
HOW TO

Run a Click Driven Script

Goal

Trigger a controlled multi-step workflow from a worksheet click.

Prerequisites

  • Runline U Add-in installed in Excel.
  • A worksheet range that lists the script steps.
  • A visible trigger cell, button-like cell, or click range.

Steps

1. Define the Trigger Cell

Use U.SET_CLICKVALS to make the cell write a recognizable trigger value.

=U.SET_CLICKVALS("RUN SCRIPT",B2,1,0,"return(calc)",,,,C7)

2. Create the Script

Use U.CREATE_SCRIPT to define the ordered steps and an optional log range.

=U.CREATE_SCRIPT(script_name, steps_range, log_range)

Historical examples use simple steps: clear old output, iterate through input rows, paste intermediate values, and append completed rows to a result area.

3. Run Only When Triggered

Use U.GET_CLICKVAL, U.EVENT, or a visible trigger cell so normal recalculation does not repeatedly run the script.

=IF(U.EVENT(U.GET_CLICKVAL($B$2)),U.RUN_SCRIPT($C$6),U.CURRENT_VALS())

4. Keep Output and Logs Separate

Clear or paste output ranges explicitly. Keep a log range visible so the user can inspect which step ran last.

Result

The workbook can run a repeatable action sequence from a click while keeping the trigger, steps, and log auditable.

Common Variations

  • Use U.NOW as a delayed or periodic trigger.
  • Use U.PASTE to write each step result into a staging range.
  • Use U.CLEAR before starting a fresh run.
  • Use U.FORMAT_STRING to build parameterized step expressions.

Troubleshooting

  • If the script runs more than once, isolate the trigger formula from volatile recalculation.
  • If a later step runs before data is ready, add an explicit readiness check before that step.
  • If users cannot diagnose failure, add or expand the script log range.