Need macro/VBA/Sub... that will paste data from the clip board into a single cell

D_Step

New Member
Joined
Nov 21, 2012
Messages
4
This macro/VAB/Sub... needs to be able to paste data into a single excel cell.
The copied data may be one word or multiple paragraphs from a word document.
Either way it needs to be pasted into one single cell.
The code needs to pick up from this point:


VBA Code:
' Paste info from clipboard starting at active cell

    ActiveCell.Select



I tried many different things that just does not work, from multiple variations of this code:

VBA Code:
Application.SendKeys ("{F2}{HOME}+{END}")



To multiple variations of this code:

VBA Code:
    ActiveCell.Select
    Selection.WrapText = True
    ActiveWorkbook.ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
        False, NoHTMLFormatting:=False



The problem with all of the things I tried is that it copies the data from the clipboard & pastes it into multiple cells, but I need the data to stay in one single cell.

I also real numerous threads here in which copying content from multiple Word documents to an Excel workbook is demonstrated and many more and none of them show how to do this. For example:
https://www.mrexcel.com/forum/gener...doc-files-into-excel-including-filenames.html
https://www.mrexcel.com/forum/gener...-multiple-word-doc-single-new-excel-file.html
https://www.mrexcel.com/forum/gener...068739-vba-excel-import-word-tables-help.html
https://www.mrexcel.com/forum/gener...cting-ms-word-form-data-into-excel-table.html
https://www.mrexcel.com/forum/gener...able-word-into-excel-based-table-headers.html
https://www.mrexcel.com/forum/gener...fic-range-remove-spaces-after-paragraphs.html
https://www.mrexcel.com/forum/gener...t-word-document-putting-them-excel-table.html


Thank you so much in advance!
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,952
Office Version
  1. 365
Platform
  1. Windows
It looks like you want to paste special, I don't know how to do that, but if it just to paste as text then try this:
Note: to work with clipboard you need to add the reference “Microsoft Forms 2.0 Object Library” (in VBE menu select Tool>References> select “Microsoft Forms 2.0 Object Library”)
VBA Code:
Sub pasteClipboard()

'you need to add the reference “Microsoft Forms 2.0 Object Library” (to work with clipboard)
Dim obj As New DataObject

obj.GetFromClipboard
ActiveCell = obj.GetText

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,126,944
Messages
5,621,751
Members
415,854
Latest member
Tutu123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top