Ich erstelle über einen Button ein neues Tabellenshett,und würde jetzt gerne ins Worksheet_Change Ereignis diesen Code beim erstellen mit einfügen. Weis jemand wie das geht.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pos As Integer
pos = InStr(Target.Cells(1, 1), "Luczyk")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=6).Font
.FontStyle = "Fett"
.ColorIndex = 3
End With
End If
pos = InStr(Target.Cells(1, 1), "Lehmann")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=7).Font
.FontStyle = "Fett"
.ColorIndex = 4
End With
End If
pos = InStr(Target.Cells(1, 1), "Cin")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=10).Font
.FontStyle = "Fett"
.ColorIndex = 5
End With
End If
pos = InStr(Target.Cells(1, 1), "Hücker")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=6).Font
.FontStyle = "Fett"
.ColorIndex = 7
End With
End If
pos = InStr(Target.Cells(1, 1), "Hamann")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=6).Font
.FontStyle = "Fett"
.ColorIndex = 1
End With
End If
pos = InStr(Target.Cells(1, 1), "Schäfer")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=7).Font
.FontStyle = "Fett"
.ColorIndex = 14
End With
End If
End Sub