Protect Data Validation cells from Copy Paste

amotto11

New Member
Joined
Feb 14, 2012
Messages
10
Hi All,

I have set data validations to many cells of my workbook, and they work great when the user inputs information into the cells, but when you copy and paste into the cells containing data validation, the cell properties are over written to where there is no longer data validation. As i understand this is what data validation is designed to do, but is there some way via VBA to make it where a user can copy paste values into cells with data validation and they are still run through the validation to see if the value fits the requirement. I have been given suggestions on how to make it so the user cannot copy and past values, but for my worksheet the user will need to input <= 200 numbers into a sheet, therefore it would be much more efficient to them to just copy and past the numbers into the 20X10 grid i have unlocked for them. the reason i say <= 200 numbers is becuase of my data validation, the amount of numbers that they can enter is based on a criteria that they give me to start the worksheet. I have data validations in this grid that say the data entered has to be a number and less than the number they input before, so i cannot use any sort of VBA code that just checks if the pasted value is a nunmber(Have been given this code in the past). I am really looking for something that can read the numbers as they are pasted in and can run them though the current data validations in each cell, becuase each cell has a different data validation. This may not be possible, but any insight will help me. I am very new to VBA, so please if you do have a solution paste your code and a little explanation of what it is doing, so that i can just copy and paste it into my worksheet and change the values to fit my needs.

Thanks in advance for any help,
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I'm not expert in VBA, but also had some issues with validation/protection and copy/pasting.

I'm not really sure I understand the rule for validation that you would need, but here are some thoughts:
1) Don't think the idea of copy/pasting sequentially is efficient. If you go that route, you can create a macro that stores the range of whatever a user copies, and then whenever they paste in your target range, the paste is "cancelled" and instead each element of the array is pasted one by one. You'll probably have to ask a more seasoned programmer how to perform that, but that's one approach. Again, I think it is inefficient.

2) You can let the user paste whatever they want, and then run a validation routine that points out which values are not in compliance with your rule. As long as it is a rule, you can program it (it doesn't matter that pieces of information of that rule are given by the user....).

Let us know if you had already solved this problem
 
Upvote 0
Pecosvil,

Your suggestions seem to be right in line with what i am trying to do, but i have not had any success being able find ways to do that. I am very new to VBA and would really have no idea how to get started. I can read and interpret code fairly well, so if you have any suggestions i could just run with it would be greatly appretiated. Thanks again for your suggestions.
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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