Highlighted copy range during Excel copy-paste

ssakthivel

New Member
Joined
May 13, 2008
Messages
5
Hello

I wonder if it is possible to access the copy-from range after the user has selected the destination range during Excel Copy-Paste.

Here is my situation. I have setup Excel Data Validations such as List, Decimal between and Text Length on certain cells. These validations work fine when user enters data in these cells ensuring only valid data go into these cells. However when user copies and pastes into these cells, values that will fail the validations still get pasted into these cells.

I do not want to disable the Excel Copy-paste function altogether. What I would like to do is override the Excel's paste function (Control V or Shift Insert) with my function that will read the copy-from range, programmatically validate the data and then paste the data values into the destination cell(s).

This thread (http://www.mrexcel.com/forum/showthread.php?t=56674) has most of what I am looking for. I need to know how to read the selected copy-from range after user has selected destination range.

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Would it work to make a backup of the cells being pasted to, using Worksheet_SelectionChange event then programattically vet the data after posting using Worksheet_Change and restore the original data if it doesn't pass muster?
 
Upvote 0
Here is how I achieved what I wanted:

Dim DataObj As New MSForms.DataObject
Dim s As String
DataObj.GetFromClipboard
On Error Resume Next
s = DataObj.GetText

The string variable s had the data from highlighted range.

Thanks Weaver for the workaround suggestions.
 
Upvote 0

Forum statistics

Threads
1,223,276
Messages
6,171,138
Members
452,381
Latest member
Nova88

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