Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Validate cell when contents are pasted into it

I have a set of cells which are validated against a list so that when someone
types content into the cell, what is typed must be consistent with the
validation list. This does not require VB code and works fine when values
are typed into the cells, but not when they are pasted.

I use the worksheet's Worksheet_SelectionChange(ByVal Target As Range)
subprocedure and an If Then statement to detect when a particular set of
cells changed, and set validation ranges according to the contents of
reference cells.

But I don't have any idea how to validate values pasted into a cell or cell
range against a list. I would appreciate any help I can get.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Validate cell when contents are pasted into it

bValid = False
for each cell in Range("ValidationRange")
if Ucase(Target.Value) = ucase(Cell.Value) then
bValid = True
exit for
end if
Next
if not bValue then
Application.Undo
End if
End Sub


--
Regards,
Tom Ogilvy

"JR_06062005" wrote in message
...
I have a set of cells which are validated against a list so that when

someone
types content into the cell, what is typed must be consistent with the
validation list. This does not require VB code and works fine when

values
are typed into the cells, but not when they are pasted.

I use the worksheet's Worksheet_SelectionChange(ByVal Target As Range)
subprocedure and an If Then statement to detect when a particular set of
cells changed, and set validation ranges according to the contents of
reference cells.

But I don't have any idea how to validate values pasted into a cell or

cell
range against a list. I would appreciate any help I can get.






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Validate cell when contents are pasted into it

I've got 2 questions regarding your answer:
1) Which Sub procedure do you recommend I put the code into?
2) Do I declare bValid as a boolean variable?

Thanks

"Tom Ogilvy" wrote:

bValid = False
for each cell in Range("ValidationRange")
if Ucase(Target.Value) = ucase(Cell.Value) then
bValid = True
exit for
end if
Next
if not bValue then
Application.Undo
End if
End Sub


--
Regards,
Tom Ogilvy

"JR_06062005" wrote in message
...
I have a set of cells which are validated against a list so that when

someone
types content into the cell, what is typed must be consistent with the
validation list. This does not require VB code and works fine when

values
are typed into the cells, but not when they are pasted.

I use the worksheet's Worksheet_SelectionChange(ByVal Target As Range)
subprocedure and an If Then statement to detect when a particular set of
cells changed, and set validation ranges according to the contents of
reference cells.

But I don't have any idea how to validate values pasted into a cell or

cell
range against a list. I would appreciate any help I can get.







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Validate cell when contents are pasted into it

I assume the change event fires when you paste. So I would recommend the
change event. (haven't tested it an don't recall)

bValid would be dimmed as boolean.

--
Regards,
Tom Ogilvy

"JR_06062005" wrote in message
...
I've got 2 questions regarding your answer:
1) Which Sub procedure do you recommend I put the code into?
2) Do I declare bValid as a boolean variable?

Thanks

"Tom Ogilvy" wrote:

bValid = False
for each cell in Range("ValidationRange")
if Ucase(Target.Value) = ucase(Cell.Value) then
bValid = True
exit for
end if
Next
if not bValue then
Application.Undo
End if
End Sub


--
Regards,
Tom Ogilvy

"JR_06062005" wrote in message
...
I have a set of cells which are validated against a list so that when

someone
types content into the cell, what is typed must be consistent with the
validation list. This does not require VB code and works fine when

values
are typed into the cells, but not when they are pasted.

I use the worksheet's Worksheet_SelectionChange(ByVal Target As Range)
subprocedure and an If Then statement to detect when a particular set

of
cells changed, and set validation ranges according to the contents of
reference cells.

But I don't have any idea how to validate values pasted into a cell or

cell
range against a list. I would appreciate any help I can get.









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
Validate Cell contents in formlua Jwbuddy386 Excel Worksheet Functions 1 July 18th 05 05:42 PM
Worksheet_Selection Change code will not allow cell contents to be copied and pasted onto the sheet it's running on KimberlyC Excel Programming 1 July 8th 05 02:51 AM
Newbie question: clear contents in first column of copy-pasted row(s) BN Excel Programming 2 October 16th 04 02:52 AM
How to validate in code the contents of a cell? Heather M. Excel Programming 1 November 11th 03 08:14 AM
Validate value in cell Mike[_40_] Excel Programming 0 August 4th 03 05:54 PM


All times are GMT +1. The time now is 08:03 AM.

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

About Us

"It's about Microsoft Excel"