Copy Excel Values and Number Formats via VBA Without Overwriting Conditional Formatting
Question details
The user needs a VBA macro to copy cell values and number formats from a source column to a destination column while preserving the destination's existing conditional formatting.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Writing a VBA macro to automate data transfer between columns without affecting existing rule-based cell formatting.
- Observed behavior
- Standard copy-pasting via VBA overwrites the destination's conditional formatting and leaves the selection in an active copy mode with a moving border.
Ensure your Excel file is saved as a Macro-Enabled Workbook (.xlsm) and that you have enabled Developer tools to run VBA code safely.
Use PasteSpecial with xlPasteValuesAndNumberFormats
This method copies only the values and the number formats, leaving the conditional formatting rules at the destination completely untouched.
Using the default copy and paste method in VBA transfers all cell properties, including conditional formatting rules. To prevent this, the PasteSpecial method allows you to specify exactly what attributes to paste.
Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel.
Insert a new module or open the existing module where your macro is stored.
Use the .Copy method on your source range. For example: Range("C3:C10").Copy
Use the .PasteSpecial method on the destination range with the argument xlPasteValuesAndNumberFormats. For example: Range("O3").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Add the line Application.CutCopyMode = False immediately after the paste command to clear the moving copy border and automatically exit copy mode.

Automate Data Transfer with WPS Spreadsheet VBA
WPS Spreadsheet offers built-in VBA support, allowing you to write, edit, and execute macros seamlessly. You can perform advanced operations like PasteSpecial to copy values and number formats without disrupting conditional formatting.
- 1. Access Developer Tools: Open WPS Spreadsheet and navigate to the 'Developer' tab on the top ribbon.
- 2. Launch the VB Editor: Click 'VB Editor' to open the macro programming environment.
- 3. Write the Macro: Enter your VBA script using the .PasteSpecial xlPasteValuesAndNumberFormats command exactly as you would in Microsoft Excel.
- 4. Run the Automation: Run the macro to automatically copy your values and formats while keeping the target conditional formatting intact.

Frequently Asked Questions
What happens if I use xlPasteValues instead of xlPasteValuesAndNumberFormats?
Using xlPasteValues will only paste the raw data. Any specific number formats (like currency symbols, dates, or decimal places) from the source cells will be lost, and the data will adopt the destination cell's default format.
Can I preserve column widths when using PasteSpecial in VBA?
Yes, but it requires an additional step. You must perform another PasteSpecial command using Paste:=xlPasteColumnWidths on the destination range right after pasting the values.
Why does a moving border remain around my copied cells after running the macro?
The moving border (or "marching ants") indicates that the application is still in copy mode. Adding Application.CutCopyMode = False at the end of your VBA script safely clears this state.




