+ Reply to Thread
Results 1 to 5 of 5

How to force a paste of values only?

  1. #1
    Joe HM
    Guest

    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. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Joe,

    Why not protect the sheet and unlock the cells the user can have access to?

    Just a suggestion,
    Leith Ross

  3. #3
    ben
    Guest

    RE: 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
    >
    >


  4. #4
    Joe HM
    Guest

    Re: How to force a paste of values only?

    Hello -

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

    Joe


  5. #5
    Forum Contributor
    Join Date
    02-03-2005
    Location
    Chicago, IL
    Posts
    101
    Ben,

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

    Thanks in advance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1