Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How can I stop format change when copying data into unlocked cells

How can I stop the format changing when I copy data into an unlocked cell in
a format protected worksheet?

I need to allow people to both enter data or copy data from another source
into cells so I have unlocked these cells but also don't want the format of
the cells to be changed. If you enter data directly the format does not
change but if you copy and paste data it changes the format.

I know you can use "copy paste special values" but would like to know if
there is some system way of doing this.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default How can I stop format change when copying data into unlocked cells

Copy/paste this into the sheet module.

Right-click on sheet tab and "View Code" to open the module.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Formula
.Undo
Target.Formula = myValue
.EnableEvents = True
End With
Application.CutCopyMode = False
End Sub


Gord Dibben MS Excel MVP


On Wed, 10 Feb 2010 21:35:01 -0800, Linty
wrote:

How can I stop the format changing when I copy data into an unlocked cell in
a format protected worksheet?

I need to allow people to both enter data or copy data from another source
into cells so I have unlocked these cells but also don't want the format of
the cells to be changed. If you enter data directly the format does not
change but if you copy and paste data it changes the format.

I know you can use "copy paste special values" but would like to know if
there is some system way of doing this.


  #3   Report Post  
Junior Member
 
Posts: 1
Default

This is an excellent solution that solved a big problem I was having, too - thank you!!

Unfortunately it's caused a smaller problem: it disables the Undo/Redo buttons - something I think my users won't appreciate. Is there anyway to prevent the formatting from changing without disabling Undo/Redo?
  #4   Report Post  
Junior Member
 
Posts: 1
Default

Gord

Does this need to be pasted into the sheet that has the target data where ifo is copy and pasted regularly or does it need to be pasted into the sheet with formulae referencing the data.

Also will it only wotj after the sheet is re-opened.

Quote:
Originally Posted by Gord Dibben View Post
Copy/paste this into the sheet module.

Right-click on sheet tab and "View Code" to open the module.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Formula
.Undo
Target.Formula = myValue
.EnableEvents = True
End With
Application.CutCopyMode = False
End Sub


Gord Dibben MS Excel MVP


On Wed, 10 Feb 2010 21:35:01 -0800, Linty
wrote:

How can I stop the format changing when I copy data into an unlocked cell in
a format protected worksheet?

I need to allow people to both enter data or copy data from another source
into cells so I have unlocked these cells but also don't want the format of
the cells to be changed. If you enter data directly the format does not
change but if you copy and paste data it changes the format.

I know you can use "copy paste special values" but would like to know if
there is some system way of doing this.
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
How to change format protection default to unlocked? Joe User[_2_] Excel Discussion (Misc queries) 2 December 17th 09 05:19 PM
Locked Several Worksheets, allow format cells/select unlocked cell Ana24 Excel Discussion (Misc queries) 2 September 26th 09 01:15 AM
Conditionally Format Unlocked Cells Thomas M. Excel Discussion (Misc queries) 1 March 31st 09 11:06 PM
How can I format unlocked cells when the work sheet is protected Ed-1503 Excel Discussion (Misc queries) 0 April 27th 07 10:42 AM
Moving from unlocked cells to unlocked cells in an excel form Stacey Lee Excel Worksheet Functions 1 April 24th 06 08:44 PM


All times are GMT +1. The time now is 09:17 AM.

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"