Skip to main content

Get Excel Column Count

Sophie avatar
Written by Sophie
Updated over a week ago

Definition and Usage

Get the number of columns in the used range of the worksheet, including any empty columns in between. This command counts all columns that contain data or have been used in the specified Excel worksheet and returns the total count as a numeric value.


Parameter Values

Input parameters

Parameter

Description

Required

Options / Notes

Excel instance

Please select an Excel instance (created via the "Launch Excel" or "Get active Excel worksheet" command) to identify the instance to operate on.

Yes

Must reference a valid Excel instance created earlier in the workflow

Worksheet name

Specify the worksheet name (leave blank for the active worksheet)

No

If left blank, the command will use the currently active worksheet

Error handling

Parameter Name

Description

Throw error & stop

When an error occurs, the action will trigger an error and stop the execution of the entire app.

Retry command

If an error occurs, the action will retry the command in an attempt to resolve the issue and continue the process.

Ignore error & continue

When an error occurs, the action will be ignored, and the workflow will continue without interruption.

Variables produced

This command produces a numeric variable that stores the count of columns in the used range of the specified worksheet.


Using Variables in Conditions

You can use the output variable in subsequent actions by referencing it with the variable icon or using {variableName} syntax. This variable can be used in:

  • Mathematical calculations

  • Conditional statements (if/else branches)

  • Loop iterations

  • Text formatting operations where numeric values are needed


Notes

  • Before using this command, ensure that a valid Excel instance has been created using "Launch Excel" or "Get active Excel worksheet" commands.

  • The column count includes all columns that contain data as well as any empty columns between data-containing columns.

  • This command only counts columns in the used range of the worksheet, not the total available columns in Excel.

  • If the specified worksheet does not exist, the command will trigger an error based on your error handling settings.

Did this answer your question?