Hvordan forebygge kopiere og lime over celle med rullegardinlisten i Excel?

1. Åpne regnearket med nedtrekkslisten celle Vil du unngå kopiere og lime.
2. Trykk Alt + F11 tastene samtidig for å åpne Microsoft Visual Basic Applications vinduet.
3. I Microsoft Visual Basic Applications vinduet, dobbeltklikker du på gjeldende regneark navn i ruten til venstre, og deretter kopiere og lime inn nedenfor VBA kode i kode editor. Se skjermbilde:
VBA-kode: Forhindre kopiere og lime over celle med nedtrekkslisten
Private Sub Worksheet_Change (ByVal Target As Range) Dim xVerdi As String Dim xCheck1 As String Dim xCheck2 As String Hvis Target.Count > 1 Så Exit Sub End If Application.EnableEvents = False xVerdi = Target.Value On Error Resume Neste xCheck1 = Target.Validation.InCellDropdown On Error GoTo 0 Application.Undo On Error Resume Neste xCheck2 = Target.Validation.InCellDropdown On Error GoTo 0 Hvis xCheck1 = xCheck2 Så Target = xVerdi Else MsgBox "Nei lime tillatt!" End If Application.EnableEvents = True End Sub4. Trykk Alt + Q tastene for å gå ut av Microsoft Visual Basic Applications vinduet.
5. Når du limer inn innhold til en celle med rullegardinliste, vil en dialogboks dukke opp for å minne deg på å lime er ikke tillatt. Se skjermbilde:
Merk: Dette VBA bare jobbe i enkelt celle lime. Hvis du kopiere og lime inn i flere celler, vil det ikke fungere
Kutools for Excel. Med mer enn 120 praktiske Excel-tillegg, gratis å prøve uten begrensning i 60 dager. Gå til DownloadFree Trial 60 daysPurchasePayPal /MyCommerce