How to Copy an Entire Excel Row to Another Worksheet Using VBA
Question details
The user wants to copy a complete row of data from one worksheet to another using a VBA macro based on specific conditions.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Automating data transfer between worksheets where an entire row needs to be copied instead of just a single cell.
- Observed behavior
- The user needs the correct VBA syntax to select and copy the entire row and paste it into a specific destination row on another sheet.
Ensure that your workbook is saved as a Macro-Enabled Workbook (.xlsm) to prevent losing your VBA code. Also, verify the exact names of your source and destination worksheets before running the macro to avoid 'Out of Range' errors.
Use the Rows.Copy Method for Direct Row Transfer
This is the most straightforward method to copy an entire row using its index number directly to a destination row.
By directly referencing the row number, you can copy the entire row in a single line of code without needing to select the sheet first.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications editor, and insert a new module from the Insert menu.
Type the code: Rows(k).Copy Sheets("DestinationSheet").Rows(destRow). Replace 'k' with your source row number variable, 'DestinationSheet' with your actual target sheet name, and 'destRow' with the destination row number.
Press F5 or click the Run button to execute the code and instantly copy the complete row to the specified destination worksheet.

Use the EntireRow Property from a Specific Cell
Use this method if your VBA condition is based on checking a specific cell and you want to copy the entire row that the cell belongs to.
Automate Data with VBA Macros in WPS Spreadsheet
WPS Spreadsheet fully supports VBA macros, allowing you to seamlessly run row-copy scripts and automate your data management just as you would in Microsoft Excel.
- 1. Install WPS Office: Download and install WPS Office, then open your macro-enabled spreadsheet.
- 2. Access the Developer Tools: Navigate to the 'Developer' tab on the ribbon and click on 'Visual Basic' to open the VBA Editor.
- 3. Insert Your Macro: Insert a new module and paste your row-copy VBA code into the editor.
- 4. Execute the Code: Run the macro to automatically copy rows between your worksheets based on your conditions.

Frequently Asked Questions
Does the VBA EntireRow method copy formatting as well as values?
Yes, when you use the standard .Copy method with EntireRow, Excel VBA copies the cell values, formulas, and all formatting (such as colors and borders) to the destination sheet.
How can I copy only the values of an entire row without formatting?
To copy only values, you must use the PasteSpecial method. First, copy the row using Rows(k).Copy, then apply it to the destination with Sheets("Destination").Rows(destRow).PasteSpecial Paste:=xlPasteValues.
Why am I getting a 'Subscript Out of Range' error when running the macro?
This error typically occurs if the worksheet name specified in your VBA code (e.g., Sheets("Alt UoM")) does not exactly match the actual name of the worksheet tab. Check for spelling mistakes or hidden trailing spaces in the sheet name.
Can I use these VBA scripts in WPS Spreadsheet?
Yes, WPS Spreadsheet has excellent VBA support. You can write, edit, and execute the exact same row-copying macros using the built-in VBA editor.




