Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Recognizing something is being pasted in code.

Hello,
I have used a worksheet as a data entry screen. I want to allow only
certain entries in the first column so I perform a validation against a
pre-defined list within the 'Worksheet_Change' event. If the entry is
valid, this entry is used to fill in other cells with associated data.
However, I have run into the possibility that the user is copying a number
of rows from another worksheet and trying to paste them into mine. This is
something that I want them to be able to do. Unfortunately, when there is
more than one row being pasted, my code fails. Is there a way to recognize
that the user is pasting so that I might bypass the validation in this
instance and perform the validation later? Or, to see that the 'Target' in
the 'Worksheet_Change' event is more than one cell? If the answer is no to
both of these, would anyone have any other suggestions? I am open to all
possibilities. Thanks for your time.

--
Bob Holmes


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Recognizing something is being pasted in code.

Hi Bob
best way: always post your code :-)

some ideas:
if target.cells.count 1 then
msgbox "more than one cell"
application.undo
end if

or loop through target:

dim cell as range
for each cell in target
if cell.value<"test_value" then
msgbox "value in cell " cell.address & " is not o.k"
application.enableevents=false
cell.clearcontents
application.enableevents=True
end if
next cell



--
Regards
Frank Kabel
Frankfurt, Germany


Bob Holmes wrote:
Hello,
I have used a worksheet as a data entry screen. I want to allow
only certain entries in the first column so I perform a validation
against a pre-defined list within the 'Worksheet_Change' event. If
the entry is valid, this entry is used to fill in other cells with
associated data. However, I have run into the possibility that the
user is copying a number of rows from another worksheet and trying to
paste them into mine. This is something that I want them to be able
to do. Unfortunately, when there is more than one row being pasted,
my code fails. Is there a way to recognize that the user is pasting
so that I might bypass the validation in this instance and perform
the validation later? Or, to see that the 'Target' in the
'Worksheet_Change' event is more than one cell? If the answer is no
to both of these, would anyone have any other suggestions? I am open
to all possibilities. Thanks for your time.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Recognizing something is being pasted in code.

Thanks a lot Frank. I'm going to try out your code and see if I can get it
to work for my purposes.
Sorry about not posting code. I thought that I'd find out if I was looking
for something that was possible first and then supply code if needed. I
really appreciate all of the information.

--
Bob Holmes MCNGP #31
"Frank Kabel" wrote in message
...
Hi Bob
best way: always post your code :-)

some ideas:
if target.cells.count 1 then
msgbox "more than one cell"
application.undo
end if

or loop through target:

dim cell as range
for each cell in target
if cell.value<"test_value" then
msgbox "value in cell " cell.address & " is not o.k"
application.enableevents=false
cell.clearcontents
application.enableevents=True
end if
next cell



--
Regards
Frank Kabel
Frankfurt, Germany


Bob Holmes wrote:
Hello,
I have used a worksheet as a data entry screen. I want to allow
only certain entries in the first column so I perform a validation
against a pre-defined list within the 'Worksheet_Change' event. If
the entry is valid, this entry is used to fill in other cells with
associated data. However, I have run into the possibility that the
user is copying a number of rows from another worksheet and trying to
paste them into mine. This is something that I want them to be able
to do. Unfortunately, when there is more than one row being pasted,
my code fails. Is there a way to recognize that the user is pasting
so that I might bypass the validation in this instance and perform
the validation later? Or, to see that the 'Target' in the
'Worksheet_Change' event is more than one cell? If the answer is no
to both of these, would anyone have any other suggestions? I am open
to all possibilities. Thanks for your time.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Recognizing something is being pasted in code.

Thank you very much, Frank. This will work fine. I can't believe it was as
simple as getting a count of the cells. The test of cells with the range
will work for other aspects of my project as well. You're a lifesaver.

--
Bob Holmes MCNGP #31
"Frank Kabel" wrote in message
...
Hi Bob
best way: always post your code :-)

some ideas:
if target.cells.count 1 then
msgbox "more than one cell"
application.undo
end if

or loop through target:

dim cell as range
for each cell in target
if cell.value<"test_value" then
msgbox "value in cell " cell.address & " is not o.k"
application.enableevents=false
cell.clearcontents
application.enableevents=True
end if
next cell



--
Regards
Frank Kabel
Frankfurt, Germany


Bob Holmes wrote:
Hello,
I have used a worksheet as a data entry screen. I want to allow
only certain entries in the first column so I perform a validation
against a pre-defined list within the 'Worksheet_Change' event. If
the entry is valid, this entry is used to fill in other cells with
associated data. However, I have run into the possibility that the
user is copying a number of rows from another worksheet and trying to
paste them into mine. This is something that I want them to be able
to do. Unfortunately, when there is more than one row being pasted,
my code fails. Is there a way to recognize that the user is pasting
so that I might bypass the validation in this instance and perform
the validation later? Or, to see that the 'Target' in the
'Worksheet_Change' event is more than one cell? If the answer is no
to both of these, would anyone have any other suggestions? I am open
to all possibilities. Thanks for your time.




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
Recognizing data george Excel Worksheet Functions 1 March 5th 08 10:28 AM
Recognizing *.xls files Nevsky Excel Discussion (Misc queries) 6 October 14th 07 03:05 AM
Macro code to center pasted data in a column Rich K. Excel Discussion (Misc queries) 2 July 9th 07 04:50 PM
recognizing double digit numbers in code DB Excel Discussion (Misc queries) 3 March 2nd 07 04:43 PM
Recognizing #N/A nebb Excel Worksheet Functions 1 October 19th 05 12:56 AM


All times are GMT +1. The time now is 10:38 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"