Excel VBA Copy Cell Value to Clipboard (4 Methods)

Most of the time, Excel users manually copy (CTRL+C) cell values and then paste (CTRL+V) them into other cells. Excel VBA copy cell value to the clipboard, makes this type of copying and pasting more convenient. Copying a specific worksheet or active worksheet’s cell value, using MSForms DataObject Library, as well as enabling select to auto copy are the discussed methods in this article. Let’s say we have a certain date’s total sales amount (i.e., E14 cell) and we want to copy the cell value to the clipboard for further pasting.

Excel VBA Copy Cell Value to Clipboard

In this article, we demonstrate the prerequisites and multiple macro variants for Excel VBA copy cell value to the clipboard.


Copy Cell Value to Clipboard in Excel VBA: 4 Easy Ways

Excel macros require module insertion prior to their execution. Follow the below instructions to be able to insert a module:

➤ Press ALT+F11 simultaneously to open the Microsoft Visual Basic window.

➤ Go to Insert > Module. Afterward, Excel opens a VBA Module where users can insert their macros.

Module Insertion

[……] Users need to double-click on a specific Sheet (under VBAProject) to insert any sheet’s codes.

Go through the latter section to find out the appropriate macro variants suitable for your case.


Method 1: Copying a Specific Worksheet’s Cell Value to Clipboard in Excel VBA

Sometimes, users have multiple Excel Worksheets within a Workbook. In that case, this macro variant is useful to copy any assigned cell values to the clipboard for later usage.

Step 1: Type the following macro in the inserted Module.

Sub Copy_SWS_CellValue_Clipboard()
Worksheets("5 Aug").Range("E14").Copy
End Sub

Method 1

Macro Explanation

  • VBA Range property takes the specific worksheet and cell value references, and after that the .Copy method copies it to the clipboard.

Step 2: After inserting the macro into the module, use the F5 key or go to Run > Run Macro F5 to execute it.

Run the Macro

Read More: Excel VBA to Copy Without Clipboard


Method 2: Excel VBA to Copy Cell Value from Active Sheet to Clipboard

As an alternative to Method 1, Excel Macros can copy an active sheet’s specific cell value and store it for further usage.

Step 1: Type the below macro in the module.

Sub Copy_AWS_CellValue_Clipboard()
ActiveSheet.Range("E14").Copy
End Sub

Method 2

Macro Explanation

  • VBA ActiveSheet.Range().Copy offers users to provide any cell copy to clipboard after its execution.

Step 2: Hit F5 or repeat Step 2 of Method 1 to execute the macro.


Method 3: Enabling Auto Copy Cell Values to Clipboard Cell in Excel VBA

What if users want to auto copy to the clipboard after selecting or highlighting a cell within a range? The VBA Intersect method secures the selection to be within a range.

Step 1: Paste the following macro into a Sheet’s Code window (Double Click on any Sheet to display the sheet code window).

Private Sub Worksheet_SelectionChange(ByVal cTarget As Range)
If Not Intersect(cTarget, Range("B4:E14")) Is Nothing Then
cTarget.Copy
End If
End Sub

Enabling Auto Copy Cell Values to Clipboard Cell in Excel VBA

Macro Explanation

  • VBA Intersect method returns a range upon the assigned Arg’s intersection.
  • VBA IF function implements a condition and performs .Copy after its affirmation.

Step 2: Now, return to the specific worksheet. And Excel automatically executes the macro.

Read More:Excel VBA: Copy Range to Clipboard


Method 4: Using Microsoft Forms Object Library to Send Cell Value to Clipboard

Users can use the Microsoft Forms Object Library to enable “Data Objects” in macros. However, they need to add the Microsoft Forms 2.0 Object Library from References first.

Activating Microsoft Forms 2.0 Object Library

To activate the Microsoft Forms Object Library, follow the below steps.

Move to Tools > Reference.

Reference-Excel VBA Copy Cell Value to Clipboard

Find the Microsoft Forms 2.0 Object Library within the Available References. After being unable to find it, click on Browse.

Clicking Browse takes you to Windows > System32. Then select FM20.DLL and click Open.

Browse

Excel activates the Microsoft Forms 2.0 Object Library, as shown in the latter image. Click OK.

Activated MSForms DataObject Library

Step 1: Type the below macro in the module.

Sub Send_CellValue_Clipboard()
Dim CellValue As MSForms.DataObject
Set CellValue = New MSForms.DataObject
CellValue.SetText ActiveSheet.Range("E14")
CellValue.PutInClipboard
End Sub

Method 4

Macro Explanation

  • The CellValue variable is assigned as DataObject and gets set to a new MSForms.DataObject.
  • Range() VBA Worksheets.Range provides a specific cell value.
  • .PutInClipboard sends the cell value to the clipboard.

Step 2: Run the macro.

Read More: How to Paste Image into Excel Cell from Clipboard


Verification of the Macros’ Outputs

We constitute all the macro variants by assuming different situations. After running or executing (pressing F5) a macro, users may want or need to confirm or paste the copied cell value into another cell.

Say we need to paste the Daily Sales (i.e., 5 Aug) into another Excel Worksheet (i.e., Sales Report) or anywhere.

Verification

🔼 So, you execute any of the macros, then return to the active worksheet or the 5 Aug worksheet. You’ll be seeing Excel copies the E14 cell or current selection (in Method 3).

🔼 Also, you can see the value getting saved in the Clipboard (Home > Click Clipboard Icon).

VBA Macro Copy Cell Value to Clipboard

🔼 Paste (CTRL+V) the value in the Sales Report worksheet as desired. You see, the value gets pasted. So, it’s obvious to say that those macros really copy the assigned cell value to the clipboard as they are supposed to.

VBA Copy Cell Value to Clipboard in Excel


⧭ Things to Keep in Mind

The offered macros only copy the cell values. Cell containing formula results in #REF error in the case of Methods 1, 2 and 3. So, make sure the cell only contains values. Otherwise, users need to paste the values as Paste as Value & Number Formatting.


Download Excel Workbook


Conclusion

This article demonstrates multiple variants of VBA Macros to cell value to the clipboard. Go through the macro explanations for a better understanding. Use any of the methods to accomplish your goal. Comment if you have further inquiries or have anything to add.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo