Copy Values (Not looking for Paste Values)

PKFillmore

New Member
Joined
Apr 3, 2012
Messages
24
Hi, im looking to create a something with VBA that will allow users to copy (values only) to the clipboard.
I know all about Paste Values however Paste Values does not work in other programs we use here at work. (Lotus notes, Java forms, etc)

I can easily come up with the code to "copy" the values of the active cell however im having difficulty on doing it with a range larger than 1

Here is my code so far....
Code:
Dim MyVar as String
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject

MyVar = Activecell.value

clipboard.SetText MyVar
clipboard.PutInClipboard

I was thinking about using a for each cell in selection loop.. but im not sure how to form it so that if the user tries to paste it back in excel it would resume the same cell order...

Code:
For Each cell In Selection
    MyVar = Cell.Value

'code that stores MyVar in a range
'and will paste in the same order it was copied as

Next

Any ideas would greatly be appreciated!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
In what way doesn't Excel's Copy method work when you try to Paste into another application?
My problem is not with the copy method but with the < paste values >
For example, We have a list of ID numbers in excel that if were were to copy/paste it into a lotus notes email it will asume the form of a table (im looking to just paste the text thats in it)

I have a few other examples I can think of as well..
 
Upvote 0
Don't you have the option to paste only text?
Yes you are correct we can paste text only. The reason I was looking into doing this is because I wanted to be able to add an extra feature in the copy method.

Depending on the report we are working with we sometimes have to drop the first or last digits of the ID number.
My end goal was to be able to modify the string from the report directly with the copy method before putting it in the clipboard
Code:
MyVar = Mid(Activecell.value, X, Y)
The arguments for X and Y would be passed down from an option I would create in the ribbon


EndGoal.jpg
[/URL][/IMG]
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

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