Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default prevent pasting to more than one row

Hi folks,

I've hit a bit of a wall and can't find a solution to the
following. . .

I have a shared workbook, in excel 2007.

The workbook contains a list of pupils' names, along with the name of
the class that they are enrolled in.

Users (teachers) select their own class name from a front page, a
macro then autofilters the list of pupils to show only those taught by
that teacher.

The whole sheet is locked, then only the visible cells are unlocked.
This is to prevent staff overwriting comments previously written.

Teachers type reports into the cells and then save them.

The problem is . . .
Many teachers prefer to type their reports in word, and copy and paste
them over to excel.

If they include line breaks or carriage returns in their report then
excel splits their comment over two cells. This isn't a problem as
usually the row below the one they are pasting to is locked.
Occasionally though staff will teach two students who are adjacent in
the class list and can overwrite the comment in the cell below the one
the are pasting to.

so. . .

Is there a way to prevent users pasting linebreaks or carriage
returns?

Many thanks
Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default prevent pasting to more than one row

Right-click the sheet tab, choose 'View Code' and paste the following VBA code into the big window
on the right side...

'---
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ThingsChange
If Target.Cells.Count 1 Then
Application.EnableEvents = False
MsgBox "Change only one cell at a time or forfeit your tenure. ", , "Blame Tony"
Application.Undo
End If
ThingsChange:
Application.EnableEvents = True
End Sub
'---

You should test/experiment with it first in a separate workbook.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(free and commercial excel programs)



"Brotherwarren"
wrote in message
...
Hi folks,

I've hit a bit of a wall and can't find a solution to the
following. . .
I have a shared workbook, in excel 2007.
The workbook contains a list of pupils' names, along with the name of
the class that they are enrolled in.
Users (teachers) select their own class name from a front page, a
macro then autofilters the list of pupils to show only those taught by
that teacher.
The whole sheet is locked, then only the visible cells are unlocked.
This is to prevent staff overwriting comments previously written.
Teachers type reports into the cells and then save them.
The problem is . . .
Many teachers prefer to type their reports in word, and copy and paste
them over to excel.
If they include line breaks or carriage returns in their report then
excel splits their comment over two cells. This isn't a problem as
usually the row below the one they are pasting to is locked.
Occasionally though staff will teach two students who are adjacent in
the class list and can overwrite the comment in the cell below the one
the are pasting to.
so. . .
Is there a way to prevent users pasting linebreaks or carriage
returns?
Many thanks
Tony



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default prevent pasting to more than one row

On May 13, 4:09*pm, "Jim Cone" wrote:
Right-click the sheet tab, choose 'View Code' and paste the following VBA code into the big window
on the right side...

'---
Private Sub Worksheet_Change(ByVal Target As Range)
*On Error GoTo ThingsChange
*If Target.Cells.Count 1 Then
* * Application.EnableEvents = False
* * MsgBox "Change only one cell at a time or forfeit your tenure. * ", , "Blame Tony"
* * Application.Undo
*End If
ThingsChange:
*Application.EnableEvents = True
End Sub
'---

You should test/experiment with it first in a separate workbook.
--
Jim Cone
Portland, Oregon USAhttp://www.mediafire.com/PrimitiveSoftware
(free and commercial excel programs)

"Brotherwarren"
wrote in ...



Hi folks,


I've hit a bit of a wall and can't find a solution to the
following. . .
I have a shared workbook, in excel 2007.
The workbook contains a list of pupils' names, along with the name of
the class that they are enrolled in.
Users (teachers) select their own class name from a front page, a
macro then autofilters the list of pupils to show only those taught by
that teacher.
The whole sheet is locked, then only the visible cells are unlocked.
This is to prevent staff overwriting comments previously written.
Teachers type reports into the cells and then save them.
The problem is *. . .
Many teachers prefer to type their reports in word, and copy and paste
them over to excel.
If they include line breaks or carriage returns in their report then
excel splits their comment over two cells. *This isn't a problem as
usually the row below the one they are pasting to is locked.
Occasionally though staff will teach two students who are adjacent in
the class list and can overwrite the comment in the cell below the one
the are pasting to.
so. . .
Is there a way to prevent users pasting linebreaks or carriage
returns?
Many thanks
Tony


Aahhh!!! So simple, thank you.

.. . . Forfeit your tenure . . . I lol'd

Thank you for you help. I'll test it out when I'm back at work on
Monday.
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
prevent changes to cell references when copying and pasting MiChaos Excel Discussion (Misc queries) 2 July 3rd 07 04:21 PM
Prevent user from copying pasting at run time sanjeet Excel Programming 0 September 23rd 06 11:27 PM
Prevent Pasting Paige Excel Programming 0 February 16th 05 07:31 PM
prevent pasting into multiple lines Bart van den Burg Excel Programming 1 November 25th 04 01:09 AM
How to prevent pasting to every sheet in workbook Nigel Brown[_2_] Excel Programming 2 January 7th 04 03:33 PM


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