To copy values only from a range to a new worksheet in Excel VBA, use the .Value property to transfer data without formulas, formatting, or links. This method ensures clean, static data is moved efficiently, ideal for reports, backups, or data sharing where live connections are unnecessary.
What You'll Need
- Microsoft Excel (any recent version supporting VBA, such as Excel 2010 or later)
- A worksheet with source data containing values or formulas you wish to copy
- Basic access to the VBA editor (press ALT + F11 to open it)
Step-by-Step
- Open your Excel workbook and navigate to the worksheet containing the data you want to copy.
- Press ALT + F11 to launch the VBA Editor.
- In the VBA Editor, go to Insert > Module to create a new module where you’ll paste the code.
- Copy and paste the following VBA code into the module window:
Sub CopyValuesOnlyToNewSheet() Dim SourceRange As Range Dim NewSheet As Worksheet ' Set the source range - adjust as needed Set SourceRange = ThisWorkbook.Sheets("Sheet1").Range("A1:D100") ' Add a new worksheet Set NewSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)) NewSheet.Name = "ValuesOnly" ' Copy only the values from source to new sheet NewSheet.Range("A1").Resize(SourceRange.Rows.Count, SourceRange.Columns.Count).Value = SourceRange.Value ' Optional: Auto-fit columns for better readability NewSheet.Columns.AutoFit MsgBox "Values copied successfully to " & NewSheet.Name, vbInformation End Sub - Modify the code if necessary:
- Change "Sheet1" to the name of your source worksheet.
- Adjust the range "A1:D100" to match your data (e.g., "A1:G500" or use
UsedRangefor dynamic sizing). - To use the active sheet, replace
ThisWorkbook.Sheets("Sheet1")withActiveSheet.
- Close the VBA Editor or click anywhere in the code window.
- Return to Excel and press ALT + F8, select
CopyValuesOnlyToNewSheet, and click Run. - A new worksheet named "ValuesOnly" will be created containing only the values from your specified range, with no formulas, formatting, or links.
- If you want to preserve column widths from the source, add this line after the value assignment:
SourceRange.Copy NewSheet.Range("A1").PasteSpecial Paste:=xlPasteColumnWidths Application.CutCopyMode = FalsePlace it inside the subroutine after the.Valueassignment and before theMsgBox.
Common Mistakes
- Using
.Copyand.PasteSpecialwithxlPasteAllinstead ofxlPasteValues, which inadvertently copies formulas and formatting. - Forgetting to qualify ranges with a worksheet object, causing the code to act on the active sheet unexpectedly.
- Not adjusting the range size, leading to truncated data or errors when the source range is larger than specified.
- Attempting to paste values into a protected worksheet without unprotecting it first, resulting in a runtime error.
- Using
SelectorActivateunnecessarily, which slows execution and can cause instability.
Tips
- Use
UsedRangeto dynamically capture all used cells:Set SourceRange = ActiveSheet.UsedRange. - Add error handling to prevent crashes if a sheet with the same name already exists:
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets("ValuesOnly").Delete
Application.DisplayAlerts = True
On Error GoTo 0
Set NewSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
NewSheet.Name = "ValuesOnly"
Application.ScreenUpdating = False Application.EnableEvents = False ' ... your code ... Application.ScreenUpdating = True Application.EnableEvents = True
Troubleshooting
- Macro not running: Ensure macros are enabled. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select "Enable all macros" (temporarily for testing) or "Disable all macros with notification".
- "Subscript out of range" error: This usually means the worksheet name in the code (e.g., "Sheet1") does not exist. Double-check the spelling and ensure the sheet is in the same workbook.
- Only formulas appear, not values: You likely used
.Formulaor pasted without using.Value. Confirm you are assigningSourceRange.Valueto the destination. - New sheet not created: If
Sheets.Addfails, another process may be protecting the workbook. Check Review > Protect Workbook and unprotect if needed. - Data is misaligned: Verify that the
.Resizedimensions match the source range. Using a fixed cell likeA1as the start point is safe if the size is correct. - Slow performance: Large ranges benefit from turning off screen updating and avoiding
Select. Use arrays for very large datasets if needed.
Frequently Asked Questions
Can I copy values only from multiple sheets at once?
Yes, loop through each worksheet in the workbook, copy its used range values to a new sheet, and name the new sheet accordingly (e.g., "Sheet1_Values").
Will this method preserve data validation or comments?
No. Copying only .Value transfers raw cell values. Data validation, comments, and formatting are not included. To preserve those, use specific PasteSpecial operations for each.
Is it safe to run this on a shared workbook?
Avoid running VBA that modifies structure (like adding sheets) in shared workbooks, as it can cause conflicts. Disable sharing, run the macro, then re-share if necessary.
How do I copy values only from a filtered list, ignoring hidden rows?
Use SpecialCells(xlCellTypeVisible) on the source range: SourceRange.SpecialCells(xlCellTypeVisible).Value — but note this requires a contiguous range or additional handling for multiple areas.
Can I undo this action?
No. VBA actions cannot be undone with Excel’s undo stack. Always work on a backup or test copy before running macros on important data.
Does this work in Excel for Mac?
Yes, the VBA editor and core functionality are largely consistent between Windows and Mac. The shortcut to open the editor is OPT + F11 on Mac.