Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default How to force a paste of values only?

Hello -

I was wondering if there is a way in an Excel macro where I can catch
the paste event to make sure the user only copies/pastes the values of
a field and not the format?

I have some conditional formatting and if the user copies a certain
cell, things get screwed up. Is there also a way to block a cut/paste?

I tried relative formatting but for some reason things get screwed up
when I run a macro that creates the relative formatting:

With lTPSheet.Range("B" & lSelection.Row & ":E" & lSelection.Row)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$D" &
lSelection.Row & "=""X"""
.FormatConditions(1).Font.ColorIndex = 2
.FormatConditions(1).Interior.ColorIndex = 3
End With

The Formula1:="=$D" & lSelection.Row & "=""X""" does NOT set the
correct row for some reason (usually off by 3) if it is a relative
reference rather than absolute ($).

Very strange unless I'm really missing something ...

Thanks!
Joe

  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default How to force a paste of values only?

I ran into something similiar to this with needing to make sure certain cells
weren't changed. Every time a user selected a cell I copied the values and
formats etc to a hidden cell. and whenever they changed a cell i compared the
hidden cell's values and formats to the one the user changed, if I didn't
like the changes I copied the hidden cell to the user changed one.

"Joe HM" wrote:

Hello -

I was wondering if there is a way in an Excel macro where I can catch
the paste event to make sure the user only copies/pastes the values of
a field and not the format?

I have some conditional formatting and if the user copies a certain
cell, things get screwed up. Is there also a way to block a cut/paste?

I tried relative formatting but for some reason things get screwed up
when I run a macro that creates the relative formatting:

With lTPSheet.Range("B" & lSelection.Row & ":E" & lSelection.Row)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$D" &
lSelection.Row & "=""X"""
.FormatConditions(1).Font.ColorIndex = 2
.FormatConditions(1).Interior.ColorIndex = 3
End With

The Formula1:="=$D" & lSelection.Row & "=""X""" does NOT set the
correct row for some reason (usually off by 3) if it is a relative
reference rather than absolute ($).

Very strange unless I'm really missing something ...

Thanks!
Joe


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default How to force a paste of values only?

Hello -

Thanks for the feedback! That sounds like a good idea ...

Joe

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to force a paste of values only?


Ben,

Did you do this with an event macro? Would you mind posting your cod
here? I'm trying to do something similar, but am kinda new to VB an
really struggling. I'd be greatful to see how you accomplished this.

Thanks in advance

--
Cel
-----------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...fo&userid=1941
View this thread: http://www.excelforum.com/showthread.php?threadid=35436

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
can you change the default paste method? (paste values) David A Brown Excel Discussion (Misc queries) 3 December 18th 07 09:59 AM
How do I force values in a cell in excel? Phyllis Excel Discussion (Misc queries) 10 February 9th 06 05:31 PM
Force values-only when pasting text to keep formatting BethP Excel Discussion (Misc queries) 2 November 17th 05 07:57 PM
How do i compare values from two sheet and copy & paste if values match? rozb Excel Programming 0 March 5th 04 12:06 AM
How to force a recalculation of values based on custom function Wim Bartsoen Excel Programming 1 October 28th 03 03:06 PM


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