How to Automatically Move Excel Rows Between Sheets with a Checkbox
Question details
The user wants to automatically transfer entire rows between a source sheet and a destination sheet based on the state of a checkbox, including moving the row back if the checkbox is unchecked.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing an Excel Trailer Log where checking a box marks a row as completed and instantly moves it to a Completed Trailer Log sheet.
- Observed behavior
- Seeking a VBA solution to automatically handle the row transfer upon checkbox interaction, as standard spreadsheet formulas cannot move rows dynamically.
Ensure that your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have enabled macros in your Excel Trust Center settings before writing VBA code.
Use a Worksheet_Change Event VBA Macro
Implement a VBA macro that listens for changes in your checkbox column and automatically cuts and pastes the row to the target sheet.
Since standard Excel formulas cannot move data or trigger actions on their own, a VBA (Visual Basic for Applications) macro is required to monitor the checkbox column. The code uses a Worksheet_Change event to trigger moving the row whenever the linked cell's value becomes True (checked) or False (unchecked).
Press Alt + F11 on your keyboard to open the VBA editor. In the left panel (Project Explorer), double-click the specific worksheet (e.g., 'Master') where your checkboxes are located.
Paste a VBA script using the 'Private Sub Worksheet_Change(ByVal Target As Range)' event. Ensure you define the target column (for example, Column A or Column H) that contains the True/False checkbox links.
Write an 'If Target.Value = True' statement to find the next empty row in the 'Completed' destination sheet, cut the entire row using 'Target.EntireRow.Cut', and paste it into the destination sheet.
Add an 'ElseIf Target.Value = False' block in the destination sheet's VBA module to detect if a checkbox is unchecked, instructing the macro to cut the row and move it back to the original 'Master' sheet.
Automate Your Workflow with WPS Spreadsheet
WPS Office offers a robust Spreadsheet application that fully supports macros, VBA functions, and seamless Excel file compatibility, making it easy to automate row transfers and manage complex logs efficiently.
- 1. Open Your Workbook: Launch WPS Spreadsheet and open your existing .xlsm file containing your trailer log and checkboxes.
- 2. Enable Macros: Navigate to the 'Developer' tab in the top ribbon and ensure macros are enabled to allow VBA execution.
- 3. Edit the VBA Code: Click on 'Visual Basic' or press Alt + F11 to open the WPS Macro Editor. Paste your Worksheet_Change event code for the row transfer logic.
- 4. Test the Automation: Return to your spreadsheet, check the box in the designated column, and verify that the row automatically moves to your Completed sheet.

Frequently Asked Questions
Why isn't my VBA macro triggering when I click the checkbox?
Form control checkboxes do not natively trigger a Worksheet_Change event unless they are linked to a specific cell. Right-click the checkbox, select 'Format Control', and link it to the cell it is placed in. The change in the cell's underlying True/False value will then trigger the macro.
Can I copy the row instead of moving it completely?
Yes. In your VBA code, replace 'Target.EntireRow.Cut' with 'Target.EntireRow.Copy'. This will duplicate the data to the destination sheet while keeping the original row intact on the master sheet.
Do ActiveX checkboxes work differently for this task?
Yes. If you insert an ActiveX checkbox instead of a Form Control checkbox, you must use the CheckBox_Click() event directly in the worksheet module, rather than monitoring a cell value change through the Worksheet_Change event.




