How to Move Excel Rows to Q1, Q2, Q3, and Q4 Sheets with VBA
Question details
The user needs a VBA macro to automatically distribute rows from a master sheet to specific quarterly sheets (Q1, Q2, Q3, Q4) based on the quarter value in column U.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing yearly data by moving records into their respective quarterly worksheets without losing the top header row.
- Observed behavior
- Rows need to be identified by their quarter value, copied to the correct target sheet, and deleted from the source sheet, ignoring any blank or invalid entries.
Always create a backup copy of your workbook before running VBA macros that delete rows, as macro actions usually cannot be undone using the standard undo shortcut.
Use a Select Case Statement with a Reverse Loop
Implement a VBA macro that reads column U from the bottom up, using a Select Case statement to correctly route and safely delete rows without skipping data.
To reliably move rows based on quarterly values and delete them from the source sheet, you must use a reverse loop (bottom to top). This ensures that deleting a row does not shift the remaining rows up and disrupt the loop's counter, which would cause adjacent rows to be skipped.
Using a Select Case statement allows the macro to neatly route rows to Q1, Q2, Q3, or Q4 worksheets, automatically bypassing any cells that contain blank or unrecognized values.
Press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor.
In the Project Explorer panel, right-click on your workbook, hover over 'Insert', and select 'Module' to create a blank script window.
Define your loop to start from the last used row and step backwards down to row 2 (e.g., 'For i = lastRow To 2 Step -1'). Stopping at row 2 prevents your column headers from being moved.
Inside the loop, read the cell value in column U. Use a 'Select Case' statement with cases for "Q1", "Q2", "Q3", and "Q4".
Under each valid case, find the next available row on the target quarterly sheet. Copy the entire row from the source sheet, paste it to the target sheet, and then use 'Rows(i).Delete' to remove it from the master sheet.

Use WPS Spreadsheet to Run Macros and Organize Data
WPS Office fully supports VBA macros, allowing you to easily automate repetitive tasks like distributing master lists into quarterly sheets. Experience a lightweight, powerful, and free solution for advanced data management.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the yearly data.
- 2. Access the Developer Tools: Navigate to the 'Developer' tab on the top ribbon and click on 'VBA Editor'.
- 3. Insert and Run the Macro: Insert a module, paste your quarterly sorting macro code, and click 'Run' to automatically distribute your rows to the Q1-Q4 sheets.

Frequently Asked Questions
Why must the VBA loop run backwards when deleting rows?
When a row is deleted, all the rows below it instantly shift up by one spot. If your loop runs forwards (top to bottom), the counter advances while the rows shift up, causing the macro to completely skip the row immediately following a deleted one. Looping backwards prevents this collision.
What happens if column U contains a blank or invalid value?
Because the macro uses a 'Select Case' statement tailored specifically for "Q1", "Q2", "Q3", and "Q4", any blank cells or unlisted values will be ignored. The macro will skip those rows, leaving them safely in the source worksheet.
How do I find the next available empty row on a target worksheet using VBA?
You can locate the next available row dynamically by using the End(xlUp) method. A common code snippet is: NextRow = TargetSheet.Cells(TargetSheet.Rows.Count, "A").End(xlUp).Row + 1.




