How to Automatically Copy an Adjacent Excel Cell to Clipboard on Selection
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.

- 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.
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.
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.
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.
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
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.

Apply the VBA Macro to Multiple Target Columns
Modify the VBA Intersect range to include multiple columns if you have pairs of data spread across the sheet (e.g., clicking A copies B, clicking C copies D).
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. Install WPS Office: Download and install WPS Office on your computer for free.
- 2. Open Your Spreadsheet: Open your existing Excel file (.xlsm) or create a new one using WPS Spreadsheet.
- 3. Access Developer Tools: Navigate to the 'Developer' tab on the top ribbon and click 'Visual Basic' to access the VBA editor.
- 4. Apply the Macro: Double-click your active worksheet in the Project window and paste the SelectionChange macro to enable automatic copying.

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.




