To copy and paste in Excel VBA, use the Range.Copy method with a destination argument: Range("A1").Copy Destination:=Range("B1"). This copies the cell's value, formatting, and formulas in one line, without touching the clipboard. For most macros that is all you need. The rest of this guide covers the variations that matter in real workbooks: copying whole columns, pasting only values, moving between sheets, and avoiding the errors that make macros fail.

What You'll Need

  • Excel on Windows or Mac with the Developer tab enabled (File > Options > Customize Ribbon > check Developer; on Mac, Excel > Preferences > Ribbon & Toolbar).
  • A workbook saved as .xlsm (macro-enabled) if you want to keep your code.
  • Basic familiarity with the VBA Editor (Alt+F11 on Windows, Option+F11 on Mac).

Step-by-Step

  1. Open the VBA Editor. Press Alt+F11 (Windows) or Option+F11 (Mac). In the Project pane, right-click your workbook, choose Insert > Module. A blank code window appears.
  2. Write a basic copy-paste macro. Type:
    Sub CopyOneCell()
    Range("A1").Copy Destination:=Range("B1")
    End Sub
    Place your cursor inside the sub and press F5 to run it. Cell A1's content, formatting, and formula (if any) now appear in B1.
  3. Copy a range. Replace the range with a block: Range("A1:C10").Copy Destination:=Range("E1"). The destination is the top-left cell of the paste area; Excel sizes it automatically. If the destination range is too small, Excel still pastes the full block.
  4. Copy to another sheet. Qualify both ranges with their sheets:
    Worksheets("Sheet1").Range("A1:A10").Copy _
    Destination:=Worksheets("Sheet2").Range("A1")
    This is the most common real-world pattern and avoids the "Select method of Range class failed" error that appears when you rely on Activate.
  5. Paste values only. The Destination argument pastes everything. To paste only values, copy first, then use PasteSpecial:
    Range("A1").Copy
    Range("B1").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    The last line clears the marching-ants border and frees the clipboard.
  6. Copy an entire column or row. Use Columns("A").Copy Destination:=Columns("C") or Rows(1).Copy Destination:=Rows(3). Avoid EntireColumn on whole-sheet operations; it is slower and can copy more than you expect.
  7. Copy between workbooks. Open both, then qualify with workbook names:
    Workbooks("Source.xlsx").Sheets(1).Range("A1:A5").Copy _
    Destination:=Workbooks("Target.xlsx").Sheets(1).Range("A1")
    Both workbooks must be open; VBA cannot copy to a closed file.
  8. Turn off screen updating for speed. At the top of longer macros add Application.ScreenUpdating = False and set it back to True before End Sub. Copy-paste loops run noticeably faster.
  9. Save and test. Press Ctrl+S (Cmd+S on Mac). Run the macro with Alt+F8, select it, and click Run. Check the destination cells for values, formatting, and formulas.

Common Mistakes

  • Forgetting Application.CutCopyMode = False. The clipboard stays active, the dashed border remains, and the next manual paste may paste the old range.
  • Using Select and Activate. Code like Range("A1").Select then Selection.Copy fails when the sheet is not active. Qualify ranges directly instead.
  • Pasting into a merged cell. Excel raises an error if the destination overlaps merged cells. Unmerge first or paste to a single unmerged cell.
  • Copying formulas that reference the wrong sheet. Relative references shift on paste. If you need the same formula everywhere, use absolute references ($A$1) or paste values.
  • Assuming Destination pastes values. It pastes everything, including formats and data validation. Use PasteSpecial when you want only part of it.
  • Copying a whole column into a table. It can overwrite headers or expand the table unexpectedly. Copy the specific data range instead.

Tips

  • Use xlPasteValues when you want to freeze results and drop formulas; use xlPasteFormats when you only want the look.
  • For large loops, read the range into a Variant array, process it, and write it back in one assignment. It is far faster than cell-by-cell copy-paste.
  • Name your ranges (Formulas > Define Name) and refer to them in VBA; the code survives inserted rows and columns.
  • Add On Error GoTo handling around copy operations so a missing sheet or locked cell gives a clear message instead of a debug prompt.
  • Test on a copy of the workbook. Copy-paste macros overwrite data silently and there is no undo inside VBA.

Troubleshooting

"Select method of Range class failed." You are using Select or Selection on a sheet that is not active. Replace with direct range references and qualify the sheet name.

"PasteSpecial method of Range class failed." Nothing is on the clipboard, or the destination overlaps merged cells. Copy first, then paste to a single cell.

"Subscript out of range." A sheet or workbook name in your code does not match the actual name. Check spelling and any trailing spaces.

Macro runs but nothing changes. Screen updating may be off and never restored, or the destination is hidden. Set Application.ScreenUpdating = True and check for hidden rows or sheets.

Runtime error 1004 on copy. Usually a protected sheet or workbook. Unprotect it in the code with ActiveSheet.Unprotect (add the password if set) and re-protect afterward.

Formats disappear after paste. You used PasteSpecial with values only. Switch to xlPasteAll or the Destination argument.

Frequently Asked Questions

Can I copy without using the clipboard?

Yes. The Destination argument performs a direct copy and does not use the clipboard, so it is faster and does not interfere with what the user has copied elsewhere.

How do I copy only visible cells from a filtered range?

Use Range("A1:A100").SpecialCells(xlCellTypeVisible).Copy and paste to the destination. This copies only the rows currently shown.

Why does my macro paste into the wrong sheet?

Unqualified ranges refer to the active sheet. Always prefix with Worksheets("Name") or Sheets(1) so the code targets the sheet you intend.

Can VBA copy to a closed workbook?

No. Both source and destination workbooks must be open. Open the target with Workbooks.Open, copy, then close and save it.

How do I copy values and number formats but not formulas?

Use PasteSpecial Paste:=xlPasteValuesAndNumberFormats. It keeps the displayed values and formatting while dropping the underlying formulas.

Does copy-paste work the same on Mac?

The VBA syntax is identical. Menu labels and keyboard shortcuts differ slightly, but Range.Copy and PasteSpecial behave the same in current Excel for Mac.