ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't Paste after Changing Cell Properties (https://www.excelbanter.com/excel-programming/394542-cant-paste-after-changing-cell-properties.html)

[email protected]

Can't Paste after Changing Cell Properties
 
Hi,

I'm using the following code to correct and flag changes on my
datasheet. There is a problem though. If I try pasting in data into my
datasheet, I can only do it once. The reason is due to changing the
cell color. To quickly test this, if you copy a cells and paste it
into another cell then change the color of any cell, you won't be able
to paste the copied data again into another cell. It seems that
changing the cell color, or indeed other cell properties, breaks the
link to the clipboard. But I must indicate to the user that a cell has
been updated, and I'd like them to be able to paste the same data
multiple times. Any suggestions?

Thanks,

Barry.

it seems that when you attempt to paste for the second time, you
can't.

Private Sub Worksheet_Change(ByVal target As Range)

If Not target Is Nothing Then

For Each cell In target.Cells
' only allow "X" or "" in cell
If cell.value < "" And cell.value < "X" Then
cell.value = "X"
' flag that the cell has been changed
Else
cell.Interior.Color = vbYellow
End If
Next cell

End If
End Sub



All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com