The "Copy rows selectively" instruction can be used to copy rows from a data range, depending on a value(s) located in a specified column(s).
One simple scenario where this instruction could be useful is when a we want to copy only the details of employees belonging to a certain department, as shown in the below example dataset.
For example, we'd like to copy only the details of employees in the Marketing department into the next sheet in the workbook.
Suppose for this example, the original dataset lies in the "Sheet1" worksheet and we desire the output dataset in "Sheet2".
2. Create an action step to manipulate data.
3. Select the "Copy rows selectively" instruction.
4. Configure the source range to select the dataset.
5. Set the target range to the desired location (in our case, in Sheet2).
6. Select the condition on which a row will be copied over.
This indicates that a row will be copied on the condition that the value in Column A equals to "Marketing".
7. Save and run the step.
Once this step completes successfully, the appropriate rows will have been copied over to the target range (Sheet2 in our example).
Useful tips and resources
The conditions in step 5 can be generalised into more than an "equals to" operator. For example, we can use a wide range of various operators including the below options.
Sometimes, the conditional value may not be fixed and can vary depending on a property elsewhere in the process. And so, instead of writing a literal value in the textbox, we can also link the value to this other property that contains a variable value by choosing "Link" instead of "Literal".
When specifying a condition, the text can be toggled depending on whether case-sensitivity is desired, using the tick-box underneath.
Also, we can specify more than one condition to be met, in order for a row to be copied.
For example, we can further condition that we desire the details of all female employees in the Marketing department.
We can do this by clicking on "Add" and specifying the new condition.
This will copy over the following rows.
Note that adding multiple conditions requires that all conditions must be met consecutively for the row to be copied over.
If however, we require that at least one out of the multiple conditions needs to be met, instead create multiple "Copy rows selectively" instructions.
To avoid copying the same row more than once, we can use the "Delete rows selectively" instruction after each "Copy rows selectively" instruction.
The file containing the example used in this article can be downloaded below.