logo
search
VBA & Macro Problems

How to Automatically Copy an Adjacent Excel Cell to Clipboard on Selection

Ayan MasoodAyan Masood Oct 9, 2026 870 views

Question details

The user wants to automatically copy the contents of an adjacent cell to the clipboard simply by clicking on a specific cell in Excel.

How to Automatically Copy an Adjacent Cell to the Clipboard on Selection in Excel
Product
Excel
Device & OS
not provided
Scenario
Automating data copying tasks where clicking on a number or designated cell instantly copies the related text in the neighboring cell to the system clipboard.
Observed behavior
Currently, users must manually select and copy the target cell. The goal is to trigger the copy action automatically using a Worksheet SelectionChange event.
Before you start

Ensure that you have enabled macros in your Excel workbook and saved it as a Macro-Enabled Workbook (.xlsm) so the VBA code can execute properly.

Solution 1Recommended

Use VBA Worksheet_SelectionChange to Copy the Adjacent Cell

Add a VBA macro to the specific worksheet module that triggers whenever a cell in a designated column is clicked, copying the cell immediately to its right.

This solution utilizes the Worksheet_SelectionChange event, which runs automatically every time a new cell is selected. By combining this with the Intersect and Offset functions, we can precisely target which cell gets copied.

1
Open the VBA Editor

Right-click the specific worksheet tab at the bottom of your Excel window (e.g., 'Sheet1') and select 'View Code' from the context menu to open the VBA Editor directly in the correct module.

2
Paste the VBA Macro

In the code window, paste the following script: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count = 1 Then If Not Intersect(Target, Range("A:A")) Is Nothing Then Target.Offset(0, 1).Copy End If End If End Sub

3
Test the Automation

Close the VBA Editor. Return to your worksheet and click any single cell in Column A. The contents of the adjacent cell in Column B will instantly be copied to your clipboard, ready to paste.

Use VBA Worksheet_SelectionChange to Copy the Adjacent Cell
Targeting the Correct Cell: The code uses Target.Offset(0, 1).Copy to target the cell exactly one column to the right of your selection. The '0' represents row offset, and the '1' represents the column offset.
Advanced Spreadsheet Automation

Easily Manage VBA Macros with WPS Office

WPS Office fully supports VBA macros, allowing you to automate repetitive tasks like copying adjacent cells just as you would in Microsoft Excel, but within a lightweight, highly compatible environment.

  1. 1. Install WPS Office: Download and install WPS Office on your computer for free.
  2. 2. Open Your Spreadsheet: Open your existing Excel file (.xlsm) or create a new one using WPS Spreadsheet.
  3. 3. Access Developer Tools: Navigate to the 'Developer' tab on the top ribbon and click 'Visual Basic' to access the VBA editor.
  4. 4. Apply the Macro: Double-click your active worksheet in the Project window and paste the SelectionChange macro to enable automatic copying.
Fully compatible with Microsoft Excel VBA scripts (.xlsm files).Lightweight and fast installation for smooth performance.Free alternative with a highly familiar user interface.Built-in Developer tools to easily manage and execute macros.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my VBA code copying the adjacent cell when I click?

This usually happens if macros are disabled in your workbook, or if the code was placed in a standard module (like Module1) instead of the specific Worksheet module. Ensure you right-clicked the sheet tab and selected 'View Code' to paste the script.

How can I copy the cell to the left instead of the right?

To copy the cell to the left, change the offset in the VBA code from Target.Offset(0, 1).Copy to Target.Offset(0, -1).Copy. Keep in mind that this will cause an error if the selected cell is in Column A, as there is no column to its left.

Will this macro work if I select multiple cells at once?

No, the provided code includes the condition 'If Target.Cells.Count = 1 Then'. This safety measure ensures the copy action only triggers when exactly one cell is selected, preventing the macro from crashing during multi-cell selections or drag-and-drop actions.