Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting Data Validation to execute when using Paste Special... Val

I know that when data is normally pasted into a cell that contains Data
Validation, the Data Validation rule is deleted/cleared.

However, if I use Paste Special... Values, for example, the Data Validation
rule is preserved, although it does not execute. It's only if I subsequently
edit the cell (after having performed Paste Special... Values) that the Data
Validation rule executes.

The code below causes copied data to be pasted only as a value (thereby
preserving the Data Validation rule). What I can't seem to figure out is how
to cause the Data Validation rule to be executed after the data has been
pasted.

Any help would be greatly appreciated.

Thanks,
Bob Z.
-----------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim myValue As String
On Error Resume Next
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = Trim(myValue)
.CutCopyMode = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Getting Data Validation to execute when using Paste Special... Val

Data validation is designed only to catch input that a user types directly
into a cell. Pasted data and data that is dropped in by a VBA procedure will
always bypass the validation setup.
--
Time is just the thing that keeps everything from happening all at once


"Bob" wrote:

I know that when data is normally pasted into a cell that contains Data
Validation, the Data Validation rule is deleted/cleared.

However, if I use Paste Special... Values, for example, the Data Validation
rule is preserved, although it does not execute. It's only if I subsequently
edit the cell (after having performed Paste Special... Values) that the Data
Validation rule executes.

The code below causes copied data to be pasted only as a value (thereby
preserving the Data Validation rule). What I can't seem to figure out is how
to cause the Data Validation rule to be executed after the data has been
pasted.

Any help would be greatly appreciated.

Thanks,
Bob Z.
-----------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim myValue As String
On Error Resume Next
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = Trim(myValue)
.CutCopyMode = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Getting Data Validation to execute when using Paste Special...Val

On Apr 30, 10:28*am, Neptune Dinosaur wrote:
Data validation is designed only to catch input that a user types directly
into a cell. *Pasted data and data that is dropped in by a VBA procedure will
always bypass the validation setup.
--
Time is just the thing that keeps everything from happening all at once



"Bob" wrote:
I know that when data is normally pasted into a cell that contains Data
Validation, the Data Validation rule is deleted/cleared.


However, if I use Paste Special... Values, for example, the Data Validation
rule is preserved, although it does not execute. *It's only if I subsequently
edit the cell (after having performed Paste Special... Values) that the Data
Validation rule executes.


The code below causes copied data to be pasted only as a value (thereby
preserving the Data Validation rule). *What I can't seem to figure out is how
to cause the Data Validation rule to be executed after the data has been
pasted.


Any help would be greatly appreciated.


Thanks,
Bob Z.
-----------------------------------------------------


Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim myValue As String
On Error Resume Next
With Application
* * .EnableEvents = False
* * myValue = Target.Value
* * .Undo
* * Target = Trim(myValue)
* * .CutCopyMode = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub- Hide quoted text -


- Show quoted text -


use
Target.PasteSpecial paste:=xlpastevalues
Target.PasteSpecial paste:=xlpastevalidation

  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting Data Validation to execute when using Paste Special...

Javed - can you tell me where exactly in my code I should insert:

Target.PasteSpecial paste:=xlpastevalues
Target.PasteSpecial paste:=xlpastevalidation

What lines in my code, if any, should I delete/replace?

Thanks,
Bob Z.


"Javed" wrote:

On Apr 30, 10:28 am, Neptune Dinosaur wrote:
Data validation is designed only to catch input that a user types directly
into a cell. Pasted data and data that is dropped in by a VBA procedure will
always bypass the validation setup.
--
Time is just the thing that keeps everything from happening all at once



"Bob" wrote:
I know that when data is normally pasted into a cell that contains Data
Validation, the Data Validation rule is deleted/cleared.


However, if I use Paste Special... Values, for example, the Data Validation
rule is preserved, although it does not execute. It's only if I subsequently
edit the cell (after having performed Paste Special... Values) that the Data
Validation rule executes.


The code below causes copied data to be pasted only as a value (thereby
preserving the Data Validation rule). What I can't seem to figure out is how
to cause the Data Validation rule to be executed after the data has been
pasted.


Any help would be greatly appreciated.


Thanks,
Bob Z.
-----------------------------------------------------


Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim myValue As String
On Error Resume Next
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = Trim(myValue)
.CutCopyMode = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub- Hide quoted text -


- Show quoted text -


use
Target.PasteSpecial paste:=xlpastevalues
Target.PasteSpecial paste:=xlpastevalidation

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste special validation Rpettis31 Excel Programming 1 March 10th 08 09:41 PM
Paste validation, Copy, Paste Special Validation Scott Excel Programming 0 December 19th 06 09:54 PM
Data Validation - Copypaste special problem WCM Excel Discussion (Misc queries) 2 October 24th 06 02:13 AM
Paste Special - Validation Lori-Wheaten Excel Discussion (Misc queries) 0 July 21st 06 03:18 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"