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.
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.
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.
- VBA Range property takes the specific worksheet and cell value references, and after that the .Copy method copies it to the clipboard.
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.
- 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
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.
➤ 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.
➤ Excel activates the Microsoft Forms 2.0 Object Library, as shown in the latter image. Click OK.
Step 1: Type the below macro in the module.
Dim CellValue As MSForms.DataObject
Set CellValue = New MSForms.DataObject
- 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.
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.
🔼 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).
🔼 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.
⧭ 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
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.