How to copy the contents of cell without control characters

aparna

New Member
Joined
Nov 4, 2005
Messages
16
Every time I copy the contents of an excel cell it copies the text box and some formating characters alongwith the contents.

Is there anyway I can copy the contents of a cell as pure text either through a macro or VBA.
 

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).
In VBA the "Copy" command copies the cell itself, so you will get all the formatting and so on with it. However, you can use "PasteSpecial" with the parameter "xlValues" to simply paste the value, or "xlFormulas" to paste the formula as plain text.
 
Upvote 0
Hang on a mo. I've just reread your query and it sounds like you want to take the value from a cell and drop it into a TextBox control on a UserForm. Is that correct? Here's how I'd do that:
Code:
TextBox1.Text = Range("cell").Value
Do either of these help?!
 
Upvote 0
Thanks for your reply Mike. What I want to actually do is - copy the contents of the cell and drop it into an application like Word, without any control or special characters.
aparna
 
Upvote 0
aparna

Try this:

1. In Excel, copy the cell(s)
2. In Word, use Edit|Paste Special...|Unformatted Text
 
Upvote 0
Thanks Peter, just wondering if there is anyway i can copy this as unformatted text so that i could drop it into an application that does not have paste-special features - like SAP or Oracle.
Aparna
 
Upvote 0
Is it just the contents of 1 cell? If so, is the cell value the result of a formula or directly entered characters?
 
Upvote 0
I can't quite remember the code, but I used a "DataObject" before to do much the same thing. Just read the value from your cell and write it to the DataObject, then copy that.

I think it was "DataObject" anyway ...
 
Upvote 0
Yep. It was:
Code:
Public Sub SetClipboardText(ByVal pText As String)
'Allows the user to put some text into the clipboard
    Dim d As DataObject
    
    Set d = New DataObject
    d.SetText pText
    
    d.PutInClipboard
End Sub
 
Upvote 0
Hi Mike,
Thanks so much for the code... but I am not able to run this. How do I run this . I have pasted this as VBA code in the current sheet. But I am not able to see this either as a macro or a VBA application.
aparna
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

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
Back
Top