How to Move Marked Items to the Next Blank Row on Another Sheet Using VBA
Question details
The user needs a VBA macro to transfer specific values marked with a 'T' from designated ranges on the active sheet to the next available empty cells on the subsequent worksheet.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Creating a digital planner where unfinished tasks or daily marked items must be pushed to the next consecutive day's worksheet without overwriting any existing entries.
- Observed behavior
- The macro must scan multiple distinct source ranges, check for a 'T' marker in an adjacent cell, and sequentially paste the data into the first blank row of the target sheet, stopping if no next sheet exists.
Ensure that the Developer tab is enabled in your spreadsheet application and that macros are permitted to run. Since VBA macro actions cannot be undone using the standard Undo feature, always save a backup copy of your workbook before executing new code.
Use a VBA Macro to Transfer Marked Data to the Next Sheet
Create a VBA subroutine that identifies the active sheet, checks for the next consecutive sheet, and loops through specified ranges to copy marked items into the first available blank cell.
This VBA procedure sets up specific arrays for the source ranges and their corresponding destination starting points. It checks the adjacent cell (offset by one column to the left) for the marker 'T' and pushes the corresponding value to the next worksheet. By utilizing a continuous loop, it ensures it finds a completely empty cell so no existing data is overwritten.
Press Alt + F11 on your keyboard to open the VBA Editor in your spreadsheet application. Go to the Insert menu at the top and select Module to create a new blank script window for your workbook.
Define your sourceSheet as ActiveSheet and nextSheet as ActiveWorkbook.Sheets(sourceSheet.Index + 1). Include error handling to trigger a Message Box if the next sheet does not exist.
Set your ranges in an Array (e.g., Array("B2:B9", "B11:B21")) and destination starting cells in another Array. Loop through these ranges, using an If statement with InStr to check for the 'T' marker in the cell offset by (0, -1).
Inside the condition, use a 'Do Until destinationCell.Value = ""' loop, setting destinationCell = destinationCell.Offset(1, 0) inside the loop. This forces the script to scan downward until it finds a blank row before pasting the sourceCell.Value.
Close the VBA Editor and return to your worksheet. Press Alt + F8, select your new macro from the list, and click Run to automatically transfer the marked items.

Automate Your Workflows Using Macros in WPS Spreadsheet
WPS Spreadsheet provides robust support for VBA and macros, allowing you to easily automate repetitive tasks like transferring planner data between sheets. With a familiar developer interface, you can write, edit, and run scripts seamlessly.
- 1. Open Your Workbook: Download and install WPS Office, then open your macro-enabled (.xlsm) daily planner workbook in WPS Spreadsheet.
- 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon. If it is hidden, you can enable it in the software's settings menu.
- 3. Open the VBA Editor: Click on the 'Visual Basic Editor' icon to open the coding environment and paste or edit your data transfer code.
- 4. Execute the Macro: Use the macro button or press Alt + F8 to run the script and instantly move your marked tasks to the next day's sheet.

Frequently Asked Questions
Why do I get a 'subscript out of range' error when running the macro?
This error typically occurs if the macro attempts to access a worksheet index that does not exist. A robust VBA script should check if there is a next sheet (e.g., checking if sourceSheet.Index + 1 exceeds the total sheet count) and stop gracefully to prevent this error.
How do I change the marker from 'T' to another letter or word?
In your VBA code, locate the text comparison function (often written as InStr). Change the 'T' string in that function's argument to your desired letter or word. Ensure the comparison type is set to vbTextCompare so that the check remains case-insensitive.
How does the macro know where to paste the data without overwriting?
The macro utilizes a 'Do Until' loop that evaluates the destination cell. If the cell contains data, the loop uses the Offset(1, 0) property to move one row down repeatedly until it lands on a completely empty cell, ensuring existing data remains untouched.
Can I use this VBA code in WPS Office?
Yes, WPS Office supports VBA macros. You need to ensure you have a version of WPS Office that includes VBA functionality installed. Once enabled, you can access the Developer tab to insert and run this exact script seamlessly.




