richtig, kleiner Fehler von mir eingearbeitet um Deine Aufmerksamkeit zu testen
Wenn Du den Code mit Copy nutzen möchtest, dann sollten da noch zwei Dinge ergänzt werden.
Die Bildschirmaktualisierung sollte abgeschaltet werden und die Zwischenablage sollte geleert werden.
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim varZ As Variant
Dim lngZ As Long, i As Long
If Target.Column = 1 And Target.Row > 2 Then
On Error GoTo errorhandler
Application.EnableEvents = False
lngZ = Selection.Rows.Count + Target.Row - 1
For i = Target.Row To lngZ
If Cells(i, 1) = "" Then
Range(Cells(i, 2), Cells(i, 46)).ClearContents
Else
Select Case Len(Application.Substitute(Cells(i, 1), " ", ""))
Case 6
Cells(i, 1) = Left(Application.Substitute(Cells(i, 1), " ", ""), 2) & _
" " & Mid(Application.Substitute(Cells(i, 1), " ", ""), 3, 2) & _
" " & Right(Application.Substitute(Cells(i, 1), " ", ""), 2)
Case 9
Cells(i, 1) = Left(Application.Substitute(Cells(i, 1), " ", ""), 3) & _
" " & Mid(Application.Substitute(Cells(i, 1), " ", ""), 4, 3) & _
" " & Right(Application.Substitute(Cells(i, 1), " ", ""), 3)
End Select
varZ = Application.Match(Cells(i, 1), Range("A3:A" & Target.Row - 1), 0)
If IsNumeric(varZ) Then
Range(Cells(i, 5), Cells(i, 15)).Value = Range(Cells(varZ + 2, 5), Cells(varZ + 2, 15)).Value
Else
Range(Cells(i, 5), Cells(i, 15)).ClearContents
End If
Application.ScreenUpdating = False
Range(Cells(3, 16), Cells(3, 46)).Copy
Cells(i, 16).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
Next i
Cells(i, 1).Select 'Falls nicht nötig dann diese Zeile löschen; ohne wird der Bereich angesprungen in die hineinkopiert wurde
End If
errorhandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
If Err Then MsgBox "Fehler-Nr.: " & Err.Number & vbLf & vbLf & Err.Description
End Sub