If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
copy & paste from other worksheet - but not allow to cut
I have a formatted area I try to keep right formatted! I have tried to use
conditional formatting, but when you paste a cell from an other worksheet, that format follow. I have tried to use the frequent suggested funktion DisableCutAndPaste below, but it doesn't allow me to copy & paste! I tried to disable some of the controls, but can't find it to work. Please help me! I enclose the whole code for the specific sheet (Blad101) if there are any of the other subs who cause any trouble. Thank you for any help! Private Sub Worksheet_Activate() ActiveSheet.Unprotect Call DisableCutAndPaste If Blad101.Range("O13") = 1 Then Call GomTommaRader_B_4_125 ' hide rows sub if checkbox = 1 ElseIf Blad101.Range("O13") = 0 Then Call TaFramRad_Alla 'unhide rows if checkbox = 0 End If ActiveSheet.Protect AllowFormattingCells:=False ActiveSheet.EnableSelection = xlUnlockedCells End Sub Private Sub Worksheet_Deactivate() Call EnableCutAndPaste End Sub Sub DisableCutAndPaste() EnableControl 21, False ' cut 'EnableControl 19, False ' copy 'EnableControl 22, False ' paste 'EnableControl 755, False ' pastespecial 'Application.OnKey "^c", "" 'Application.OnKey "^v", "" 'Application.OnKey "+{DEL}", "" 'Application.OnKey "+{INSERT}", "" Application.CellDragAndDrop = False End Sub Sub EnableCutAndPaste() EnableControl 21, True ' cut EnableControl 19, True ' copy EnableControl 22, True ' paste EnableControl 755, True ' pastespecial Application.OnKey "^c" Application.OnKey "^v" Application.OnKey "+{DEL}" Application.OnKey "+{INSERT}" Application.CellDragAndDrop = True End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub |
Thread Tools | |
Display Modes | |
|
|