Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Restrict user's ability to paste into cells

Hi All,

I would like to restrict what a user can paste into a cell - values only. I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro shortcut -
the rest of the code does not seem to work.

Any ideas please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Restrict user's ability to paste into cells

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on the sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell - values only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Restrict user's ability to paste into cells

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to copy
and paste formulas into the sheet, or entering formulas of their own within
the sheet.

However, I also want to stop them from pasting in cells that could change
the format of those in the sheet, as they currently contains conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on the sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell - values only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Restrict user's ability to paste into cells

Hi Zone,

The code you provided now interferes with another piece of code I have to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to copy
and paste formulas into the sheet, or entering formulas of their own within
the sheet.

However, I also want to stop them from pasting in cells that could change
the format of those in the sheet, as they currently contains conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on the sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell - values only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Restrict user's ability to paste into cells

Hi ewan. Sorry my solution didn't work for you. I thought you would have
the sheet protected, since sheet protection offers several options to
protect formatting. Maybe that's not feasible in your situation, since you
seem to want the users to be able to do some cutting and pasting but not
some. BTW, if my solution interferes with one of your procedures, you can
temporarily disable it like this:
application.enableevents=false
'do your stuff
application.enableevents=true
and of course you can temporarily disable sheet protection and re-enable it,
as well, James

"ewan7279" wrote in message
...
Hi Zone,

The code you provided now interferes with another piece of code I have to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to
copy
and paste formulas into the sheet, or entering formulas of their own
within
the sheet.

However, I also want to stop them from pasting in cells that could change
the format of those in the sheet, as they currently contains conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I
pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on the
sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell - values
only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Restrict user's ability to paste into cells

Hi James,

In Brief:

The worsksheet is protected, with certain cells unprotected for the user to
enter data. There are many users at many locations who all have different
ways to produce their data and they do this in separate worksheets. They are
likely to copy and paste the results of this work into the sheet that I
provide them.

My sheet contains conditional formatting (yellow if blank) to show cells
that require data input. There is also a 'traffic light' formatting (green,
amber, red) to show the severity of error rates.

When the user copies and pastes data into my sheet, they can 'paste over'
this formatting, even though the sheet is protected, because the cells into
which they are entering data are unlocked.

With your code and enableevents, plus the ctrl+V shortcut for a Paste Values
macro, I am half way to what I need. What I finally need is a way to disable
the right-click Paste, Edit=Paste and Menu Bar Paste button. Is there a way
to do this?

Do you think a suggestion for levels of protection would be a good idea? It
would solve the problem in my case if I could lock the cell to
'Values/Numbers only' or something similar before protecting the sheet...

"Zone" wrote:

Hi ewan. Sorry my solution didn't work for you. I thought you would have
the sheet protected, since sheet protection offers several options to
protect formatting. Maybe that's not feasible in your situation, since you
seem to want the users to be able to do some cutting and pasting but not
some. BTW, if my solution interferes with one of your procedures, you can
temporarily disable it like this:
application.enableevents=false
'do your stuff
application.enableevents=true
and of course you can temporarily disable sheet protection and re-enable it,
as well, James

"ewan7279" wrote in message
...
Hi Zone,

The code you provided now interferes with another piece of code I have to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to
copy
and paste formulas into the sheet, or entering formulas of their own
within
the sheet.

However, I also want to stop them from pasting in cells that could change
the format of those in the sheet, as they currently contains conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I
pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on the
sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell - values
only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Restrict user's ability to paste into cells

ewan, I don't know how to disable the paste functions you mentioned other
than to protect the sheet using the default protection options, which would
disable all pasting. Then your ctrl-v routine could unprotect the sheet,
paste the values and reprotect the sheet. The only drawback to this is the
users wouldn't be able to just type into a cell. If that's a problem, you
might try posting a new message for help on disabling those specific pasting
methods. HTH, James

"ewan7279" wrote in message
...
Hi James,

In Brief:

The worsksheet is protected, with certain cells unprotected for the user
to
enter data. There are many users at many locations who all have different
ways to produce their data and they do this in separate worksheets. They
are
likely to copy and paste the results of this work into the sheet that I
provide them.

My sheet contains conditional formatting (yellow if blank) to show cells
that require data input. There is also a 'traffic light' formatting
(green,
amber, red) to show the severity of error rates.

When the user copies and pastes data into my sheet, they can 'paste over'
this formatting, even though the sheet is protected, because the cells
into
which they are entering data are unlocked.

With your code and enableevents, plus the ctrl+V shortcut for a Paste
Values
macro, I am half way to what I need. What I finally need is a way to
disable
the right-click Paste, Edit=Paste and Menu Bar Paste button. Is there a
way
to do this?

Do you think a suggestion for levels of protection would be a good idea?
It
would solve the problem in my case if I could lock the cell to
'Values/Numbers only' or something similar before protecting the sheet...

"Zone" wrote:

Hi ewan. Sorry my solution didn't work for you. I thought you would
have
the sheet protected, since sheet protection offers several options to
protect formatting. Maybe that's not feasible in your situation, since
you
seem to want the users to be able to do some cutting and pasting but not
some. BTW, if my solution interferes with one of your procedures, you
can
temporarily disable it like this:
application.enableevents=false
'do your stuff
application.enableevents=true
and of course you can temporarily disable sheet protection and re-enable
it,
as well, James

"ewan7279" wrote in message
...
Hi Zone,

The code you provided now interferes with another piece of code I have
to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to
copy
and paste formulas into the sheet, or entering formulas of their own
within
the sheet.

However, I also want to stop them from pasting in cells that could
change
the format of those in the sheet, as they currently contains
conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I
pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on
the
sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell -
values
only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Restrict user's ability to paste into cells

Hi James, check this: http://www.vbaexpress.com/kb/getarticle.php?kb_id=373


"Zone" wrote:

ewan, I don't know how to disable the paste functions you mentioned other
than to protect the sheet using the default protection options, which would
disable all pasting. Then your ctrl-v routine could unprotect the sheet,
paste the values and reprotect the sheet. The only drawback to this is the
users wouldn't be able to just type into a cell. If that's a problem, you
might try posting a new message for help on disabling those specific pasting
methods. HTH, James

"ewan7279" wrote in message
...
Hi James,

In Brief:

The worsksheet is protected, with certain cells unprotected for the user
to
enter data. There are many users at many locations who all have different
ways to produce their data and they do this in separate worksheets. They
are
likely to copy and paste the results of this work into the sheet that I
provide them.

My sheet contains conditional formatting (yellow if blank) to show cells
that require data input. There is also a 'traffic light' formatting
(green,
amber, red) to show the severity of error rates.

When the user copies and pastes data into my sheet, they can 'paste over'
this formatting, even though the sheet is protected, because the cells
into
which they are entering data are unlocked.

With your code and enableevents, plus the ctrl+V shortcut for a Paste
Values
macro, I am half way to what I need. What I finally need is a way to
disable
the right-click Paste, Edit=Paste and Menu Bar Paste button. Is there a
way
to do this?

Do you think a suggestion for levels of protection would be a good idea?
It
would solve the problem in my case if I could lock the cell to
'Values/Numbers only' or something similar before protecting the sheet...

"Zone" wrote:

Hi ewan. Sorry my solution didn't work for you. I thought you would
have
the sheet protected, since sheet protection offers several options to
protect formatting. Maybe that's not feasible in your situation, since
you
seem to want the users to be able to do some cutting and pasting but not
some. BTW, if my solution interferes with one of your procedures, you
can
temporarily disable it like this:
application.enableevents=false
'do your stuff
application.enableevents=true
and of course you can temporarily disable sheet protection and re-enable
it,
as well, James

"ewan7279" wrote in message
...
Hi Zone,

The code you provided now interferes with another piece of code I have
to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able to
copy
and paste formulas into the sheet, or entering formulas of their own
within
the sheet.

However, I also want to stop them from pasting in cells that could
change
the format of those in the sheet, as they currently contains
conditional
formatting. With your solution, the user is still able to 'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website I
pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the entire
worksheet, then this should work. Copy this code, right-click on
the
sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell -
values
only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Restrict user's ability to paste into cells

Interesting, ewan. Thanks for turning me on to that. Cheers, James

"ewan7279" wrote in message
...
Hi James, check this:
http://www.vbaexpress.com/kb/getarticle.php?kb_id=373


"Zone" wrote:

ewan, I don't know how to disable the paste functions you mentioned other
than to protect the sheet using the default protection options, which
would
disable all pasting. Then your ctrl-v routine could unprotect the sheet,
paste the values and reprotect the sheet. The only drawback to this is
the
users wouldn't be able to just type into a cell. If that's a problem,
you
might try posting a new message for help on disabling those specific
pasting
methods. HTH, James

"ewan7279" wrote in message
...
Hi James,

In Brief:

The worsksheet is protected, with certain cells unprotected for the
user
to
enter data. There are many users at many locations who all have
different
ways to produce their data and they do this in separate worksheets.
They
are
likely to copy and paste the results of this work into the sheet that I
provide them.

My sheet contains conditional formatting (yellow if blank) to show
cells
that require data input. There is also a 'traffic light' formatting
(green,
amber, red) to show the severity of error rates.

When the user copies and pastes data into my sheet, they can 'paste
over'
this formatting, even though the sheet is protected, because the cells
into
which they are entering data are unlocked.

With your code and enableevents, plus the ctrl+V shortcut for a Paste
Values
macro, I am half way to what I need. What I finally need is a way to
disable
the right-click Paste, Edit=Paste and Menu Bar Paste button. Is there
a
way
to do this?

Do you think a suggestion for levels of protection would be a good
idea?
It
would solve the problem in my case if I could lock the cell to
'Values/Numbers only' or something similar before protecting the
sheet...

"Zone" wrote:

Hi ewan. Sorry my solution didn't work for you. I thought you would
have
the sheet protected, since sheet protection offers several options to
protect formatting. Maybe that's not feasible in your situation,
since
you
seem to want the users to be able to do some cutting and pasting but
not
some. BTW, if my solution interferes with one of your procedures, you
can
temporarily disable it like this:
application.enableevents=false
'do your stuff
application.enableevents=true
and of course you can temporarily disable sheet protection and
re-enable
it,
as well, James

"ewan7279" wrote in message
...
Hi Zone,

The code you provided now interferes with another piece of code I
have
to
update certain cells in the sheet unfortunately.

I think the solution must only lie in the paste property somehow...

I'll keep trying...

"ewan7279" wrote:

Hi Zone,

Thanks for this bit of code - it will stop the user from being able
to
copy
and paste formulas into the sheet, or entering formulas of their
own
within
the sheet.

However, I also want to stop them from pasting in cells that could
change
the format of those in the sheet, as they currently contains
conditional
formatting. With your solution, the user is still able to
'PasteAll',
damaging the existing formatting.

Any ideas how to get round this, or why the solution on the website
I
pasted
into my original post worked for another user but not me?

Thanks.

"Zone" wrote:

If you want the user to only be able to enter values into the
entire
worksheet, then this should work. Copy this code, right-click on
the
sheet
tab, select View Code, and paste the code in there. HTH, James

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Formula, 1) = "=" Then
Target.ClearContents
Target.Select
MsgBox "Please enter values only.", vbExclamation
End If
End Sub

"ewan7279" wrote in message
...
Hi All,

I would like to restrict what a user can paste into a cell -
values
only.
I
found a response to another question
(http://p2p.wrox.com/topic.asp?TOPIC_...ame=topic.asp),
but it only works by changing the ctrl+v to a paste special
macro
shortcut -
the rest of the code does not seem to work.

Any ideas please?











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
RESTRICT TO PASTE VALUES ONLY FARAZ QURESHI Excel Discussion (Misc queries) 3 September 8th 08 04:06 PM
RESTRICT PASTE Gator Girl Excel Worksheet Functions 0 August 29th 07 07:46 PM
Ability to paste from Picture Manager to Excel New SMS Admin Setting up and Configuration of Excel 1 September 17th 06 04:23 AM
Restrict copy paste ability wana be xl master Excel Programming 3 February 22nd 06 07:24 PM
Have lost the ability to paste from the keyboard or menu Bob Reynolds Excel Discussion (Misc queries) 1 January 9th 06 05:44 PM


All times are GMT +1. The time now is 09:15 PM.

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"